src/Encoder/ArrayEncoder.php
private function getPairs(array $array, $space, $omit, callable $encode, & $omitted = true)
    {
        $pairs = [];
        $nextIndex = 0;
        $omitted = true;
        $format = '%s' . $space . '=>' . $space . '%s';

        foreach ($array as $key => $value) {
            if ($omit && $this->canOmitKey($key, $nextIndex)) {
                $pairs[] = $encode($value, 1);
            } else {
                $pairs[] = sprintf($format, $encode($key, 1), $encode($value, 1));
                $omitted = false;
            }
        }

        return $pairs;
    }
private function getPairs(array $array, $space, $omit, callable $encode, & $omitted = true)
    {
        $pairs = [];
        $nextIndex = 0;
        $omitted = true;
        $format = '%s' . $space . '=>' . $space . '%s';

        foreach ($array as $key => $value) {
            if ($omit && $this->canOmitKey($key, $nextIndex)) {
                $pairs[] = $encode($value, 1);
            } else {
                $pairs[] = sprintf($format, $encode($key, 1), $encode($value, 1));
                $omitted = false;
            }
        }

        return $pairs;
    }
private function getPairs ( array $ array , $ space , $ omit , callable $ encode , & $ omitted = true ) { $ pairs = [ ] ; $ nextIndex = 0 ; $ omitted = true ; $ format = '%s' . $ space . '=>' . $ space . '%s' ; foreach ( $ array as $ key => $ value ) { if ( $ omit && $ this -> canOmitKey ( $ key , $ nextIndex ) ) { $ pairs [ ] = $ encode ( $ value , 1 ) ; } else { $ pairs [ ] = sprintf ( $ format , $ encode ( $ key , 1 ) , $ encode ( $ value , 1 ) ) ; $ omitted = false ; } } return $ pairs ; }
Returns each key and value pair encoded as array assignment.
@param array $array Array to convert into code
@param string $space Whitespace between array assignment operator
@param bool $omit True to omit unnecessary keys, false to not
@param callable $encode Callback used to encode values
@param bool $omitted Set to true, if all the keys were omitted, false otherwise
@return string[] Each of key and value pair encoded as php
Returns each key and value pair encoded as array assignment .