public function addPath($path, $key = null)
    {
        // If path element is subclass of PathLocatorInterface, just put it in path bag.
        // You can create any your Path locator class implements from PathLocatorInterface.
        if ($path instanceof PathLocatorInterface) {
            // Nothing to do
        } elseif (is_string($path) || !$path) {
            // If this element is a path string, we create a PathLocator to wrap it.
            $path = new PathLocator($path);
        } else {
            // If type of this element not match our interface, throw exception.
            throw new \InvalidArgumentException(
                'PathCollection need every path element instance of PathLocatorInterface.'
            );
        }

        if ($key) {
            parent::offsetSet($key, $path);
        } else {
            parent::append($path);
        }

        return $this;
    }
public function addPath($path, $key = null)
    {
        // If path element is subclass of PathLocatorInterface, just put it in path bag.
        // You can create any your Path locator class implements from PathLocatorInterface.
        if ($path instanceof PathLocatorInterface) {
            // Nothing to do
        } elseif (is_string($path) || !$path) {
            // If this element is a path string, we create a PathLocator to wrap it.
            $path = new PathLocator($path);
        } else {
            // If type of this element not match our interface, throw exception.
            throw new \InvalidArgumentException(
                'PathCollection need every path element instance of PathLocatorInterface.'
            );
        }

        if ($key) {
            parent::offsetSet($key, $path);
        } else {
            parent::append($path);
        }

        return $this;
    }
public function addPath ( $ path , $ key = null ) { // If path element is subclass of PathLocatorInterface, just put it in path bag. // You can create any your Path locator class implements from PathLocatorInterface. if ( $ path instanceof PathLocatorInterface ) { // Nothing to do } elseif ( is_string ( $ path ) || ! $ path ) { // If this element is a path string, we create a PathLocator to wrap it. $ path = new PathLocator ( $ path ) ; } else { // If type of this element not match our interface, throw exception. throw new \ InvalidArgumentException ( 'PathCollection need every path element instance of PathLocatorInterface.' ) ; } if ( $ key ) { parent :: offsetSet ( $ key , $ path ) ; } else { parent :: append ( $ path ) ; } return $ this ; }
Add one path to bag.

@param   mixed  $path   The path your want to store in bag,
have to be a string or PathLocator object.
@param   string $key    Path key, useful when you want to remove a path.

@throws \InvalidArgumentException
@return  PathCollection  Return this object to support chaining.

@since  2.0
Add one path to bag .