createForUnknownMethod() public static method

public static createForUnknownMethod ( string $method ) : BadMethodCallException
$method string
return BadMethodCallException
Example #1
0
 public function __call(string $method, array $arguments)
 {
     if (array_key_exists($method, $this->cache)) {
         return $this->cache[$method];
     }
     if (false === preg_match('/^get.*/', $method)) {
         throw BadMethodCallExceptionFactory::createForUnknownMethod($method);
     }
     $realMethod = str_replace('get', 'create', $method);
     if ($realMethod === $this->previous) {
         throw BadMethodCallExceptionFactory::createForUnknownMethod($method);
     }
     $this->previous = $realMethod;
     $service = $this->{$realMethod}(...$arguments);
     $this->cache[$method] = $service;
     return $service;
 }