src/Guzzle/Service/Command/Factory/CompositeFactory.php
public function add(FactoryInterface $factory, $before = null)
    {
        $pos = null;

        if ($before) {
            foreach ($this->factories as $i => $f) {
                if ($before instanceof FactoryInterface) {
                    if ($f === $before) {
                        $pos = $i;
                        break;
                    }
                } elseif (is_string($before)) {
                    if ($f instanceof $before) {
                        $pos = $i;
                        break;
                    }
                }
            }
        }

        if ($pos === null) {
            $this->factories[] = $factory;
        } else {
            array_splice($this->factories, $i, 0, array($factory));
        }

        return $this;
    }
public function add(FactoryInterface $factory, $before = null)
    {
        $pos = null;

        if ($before) {
            foreach ($this->factories as $i => $f) {
                if ($before instanceof FactoryInterface) {
                    if ($f === $before) {
                        $pos = $i;
                        break;
                    }
                } elseif (is_string($before)) {
                    if ($f instanceof $before) {
                        $pos = $i;
                        break;
                    }
                }
            }
        }

        if ($pos === null) {
            $this->factories[] = $factory;
        } else {
            array_splice($this->factories, $i, 0, array($factory));
        }

        return $this;
    }
public function add ( FactoryInterface $ factory , $ before = null ) { $ pos = null ; if ( $ before ) { foreach ( $ this -> factories as $ i => $ f ) { if ( $ before instanceof FactoryInterface ) { if ( $ f === $ before ) { $ pos = $ i ; break ; } } elseif ( is_string ( $ before ) ) { if ( $ f instanceof $ before ) { $ pos = $ i ; break ; } } } } if ( $ pos === null ) { $ this -> factories [ ] = $ factory ; } else { array_splice ( $ this -> factories , $ i , 0 , array ( $ factory ) ) ; } return $ this ; }
Add a command factory to the chain

@param FactoryInterface        $factory Factory to add
@param string|FactoryInterface $before  Insert the new command factory before a command factory class or object
matching a class name.
@return CompositeFactory
Add a command factory to the chain