src/Encoder/ArrayEncoder.php
private function getAlignedPairs(array $array, callable $encode)
    {
        $keys = [];
        $values = [];

        foreach ($array as $key => $value) {
            $keys[] = $encode($key, 1);
            $values[] = $encode($value, 1);
        }

        $format = sprintf('%%-%ds => %%s', max(array_map('strlen', $keys)));
        $pairs = [];

        for ($i = 0, $count = \count($keys); $i < $count; $i++) {
            $pairs[] = sprintf($format, $keys[$i], $values[$i]);
        }

        return $pairs;
    }
private function getAlignedPairs(array $array, callable $encode)
    {
        $keys = [];
        $values = [];

        foreach ($array as $key => $value) {
            $keys[] = $encode($key, 1);
            $values[] = $encode($value, 1);
        }

        $format = sprintf('%%-%ds => %%s', max(array_map('strlen', $keys)));
        $pairs = [];

        for ($i = 0, $count = \count($keys); $i < $count; $i++) {
            $pairs[] = sprintf($format, $keys[$i], $values[$i]);
        }

        return $pairs;
    }
private function getAlignedPairs ( array $ array , callable $ encode ) { $ keys = [ ] ; $ values = [ ] ; foreach ( $ array as $ key => $ value ) { $ keys [ ] = $ encode ( $ key , 1 ) ; $ values [ ] = $ encode ( $ value , 1 ) ; } $ format = sprintf ( '%%-%ds => %%s' , max ( array_map ( 'strlen' , $ keys ) ) ) ; $ pairs = [ ] ; for ( $ i = 0 , $ count = \ count ( $ keys ) ; $ i < $ count ; $ i ++ ) { $ pairs [ ] = sprintf ( $ format , $ keys [ $ i ] , $ values [ $ i ] ) ; } return $ pairs ; }
Returns each encoded key and value pair with aligned assignment operators.
@param array $array Array to convert into code
@param callable $encode Callback used to encode values
@return string[] Each of key and value pair encoded as php
Returns each encoded key and value pair with aligned assignment operators .