src/PeekAndPoke/Component/Formal/Accessor/AccessorChain.php
protected function setFromPath(array $path, $value, $subject)
    {
        $first = array_shift($path);

        // termination condition of the recursion
        if (count($path) === 0) {
            return $this->applyChainForSet($first, $value, $subject);
        }

        // get the first parts of the chain
        $item = $this->applyChainForGet($first, $subject);
        // do the recursion
        $after = $this->setFromPath($path, $value, $item);

        // If the outcome is a completely different "thing" e.g. an array which cannot be passed around by reference
        // we need write the result back to the subject
        if ($item !== $after) {
            $this->applyChainForSet($first, $after, $subject);
        }

        // return the outcome of the set operation
        return $subject;
    }
protected function setFromPath(array $path, $value, $subject)
    {
        $first = array_shift($path);

        // termination condition of the recursion
        if (count($path) === 0) {
            return $this->applyChainForSet($first, $value, $subject);
        }

        // get the first parts of the chain
        $item = $this->applyChainForGet($first, $subject);
        // do the recursion
        $after = $this->setFromPath($path, $value, $item);

        // If the outcome is a completely different "thing" e.g. an array which cannot be passed around by reference
        // we need write the result back to the subject
        if ($item !== $after) {
            $this->applyChainForSet($first, $after, $subject);
        }

        // return the outcome of the set operation
        return $subject;
    }
protected function setFromPath ( array $ path , $ value , $ subject ) { $ first = array_shift ( $ path ) ; // termination condition of the recursion if ( count ( $ path ) === 0 ) { return $ this -> applyChainForSet ( $ first , $ value , $ subject ) ; } // get the first parts of the chain $ item = $ this -> applyChainForGet ( $ first , $ subject ) ; // do the recursion $ after = $ this -> setFromPath ( $ path , $ value , $ item ) ; // If the outcome is a completely different "thing" e.g. an array which cannot be passed around by reference // we need write the result back to the subject if ( $ item !== $ after ) { $ this -> applyChainForSet ( $ first , $ after , $ subject ) ; } // return the outcome of the set operation return $ subject ; }
@param array $path
@param       $value
@param       $subject

@return mixed
@param array $path @param $value @param $subject