src/Rasterization/Path/SVGPathParser.php
private function parseCommandChain($id, array $args, array &$commands)
    {
        if (!isset(self::$commandLengths[$id])) {
            // unknown command
            return false;
        }

        $length = self::$commandLengths[$id];

        if ($length === 0) {
            if (count($args) > 0) {
                return false;
            }
            $commands[] = array(
                'id'    => $id,
                'args'  => $args,
            );
            return true;
        }

        foreach (array_chunk($args, $length) as $subArgs) {
            if (count($subArgs) !== $length) {
                return false;
            }
            $commands[] = array(
                'id'    => $id,
                'args'  => array_map('floatval', $subArgs),
            );
            // If a MoveTo command is followed by additional coordinate pairs,
            // those are interpreted as implicit LineTo commands
            if ($id === 'M') {
                $id = 'L';
            } elseif ($id === 'm') {
                $id = 'l';
            }
        }

        return true;
    }
private function parseCommandChain($id, array $args, array &$commands)
    {
        if (!isset(self::$commandLengths[$id])) {
            // unknown command
            return false;
        }

        $length = self::$commandLengths[$id];

        if ($length === 0) {
            if (count($args) > 0) {
                return false;
            }
            $commands[] = array(
                'id'    => $id,
                'args'  => $args,
            );
            return true;
        }

        foreach (array_chunk($args, $length) as $subArgs) {
            if (count($subArgs) !== $length) {
                return false;
            }
            $commands[] = array(
                'id'    => $id,
                'args'  => array_map('floatval', $subArgs),
            );
            // If a MoveTo command is followed by additional coordinate pairs,
            // those are interpreted as implicit LineTo commands
            if ($id === 'M') {
                $id = 'L';
            } elseif ($id === 'm') {
                $id = 'l';
            }
        }

        return true;
    }
private function parseCommandChain ( $ id , array $ args , array & $ commands ) { if ( ! isset ( self :: $ commandLengths [ $ id ] ) ) { // unknown command return false ; } $ length = self :: $ commandLengths [ $ id ] ; if ( $ length === 0 ) { if ( count ( $ args ) > 0 ) { return false ; } $ commands [ ] = array ( 'id' => $ id , 'args' => $ args , ) ; return true ; } foreach ( array_chunk ( $ args , $ length ) as $ subArgs ) { if ( count ( $ subArgs ) !== $ length ) { return false ; } $ commands [ ] = array ( 'id' => $ id , 'args' => array_map ( 'floatval' , $ subArgs ) , ) ; // If a MoveTo command is followed by additional coordinate pairs, // those are interpreted as implicit LineTo commands if ( $ id === 'M' ) { $ id = 'L' ; } elseif ( $ id === 'm' ) { $ id = 'l' ; } } return true ; }
Groups the given argument chain into sets and constructs a command array
for every set, which is then pushed to the given array reference.

@param string   $id       The command id that the arguments belong to.
@param string[] $args     All of the arguments following the command.
@param array[]  $commands The array to add all parsed commands to.

@return bool Whether the command is known AND the arg count is correct.
Groups the given argument chain into sets and constructs a command array for every set which is then pushed to the given array reference .