/**
  * Delegate a method call to a subpart
  *
  * @param string $method Method nae
  * @param array $subparts Subpart identifiers
  * @param array $arguments Method arguments
  * @return mixed Method result
  */
 public function delegate($method, array $subparts, array $arguments)
 {
     // If there are subpart identifiers: Delegate method call
     if (count($subparts)) {
         $occurrence = 0;
         $part = '';
         $subpart = $this->getImmediateSubpart($subparts, $occurrence, $part);
         $result = $subpart->delegate($method, $subparts, $arguments);
         // If it's a setter method
         if (!strncmp('set', $method, 3)) {
             // Exchange the modified part
             $this->occurrences[$occurrence][$part] = $result;
             // Return a self reference
             return $this;
         }
         // Return the method result
         return $result;
     }
     return parent::delegate($method, $subparts, $arguments);
 }
Example #2
0
 /**
  * Delegate a method call to a subpart
  *
  * @param string $method Method nae
  * @param array $subparts Subpart identifiers
  * @param array $arguments Method arguments
  * @return mixed Method result
  * @throws InvalidArgumentException If there are subpart identifiers
  */
 public function delegate($method, array $subparts, array $arguments)
 {
     // If there are subpart identifiers given
     if (count($subparts)) {
         throw new InvalidArgumentException(sprintf('Subparts are not allowed (%s)', implode('/', $subparts)), InvalidArgumentException::SUBPARTS_NOT_ALLOWED);
     }
     return parent::delegate($method, $subparts, $arguments);
 }