public function callStaticMethod($class, $method, array $args = []) { $refl = new \reflectionClass($class); // Check that method is static AND public if ($refl->hasMethod($method) && $refl->getMethod($method)->isStatic() && $refl->getMethod($method)->isPublic()) { return call_user_func_array($class . '::' . $method, $args); } throw new \RuntimeException(sprintf('Invalid static method call for class %s and method %s', $class, $method)); }
protected static function canInstanciateClass($class) { $reflection = new \reflectionClass($class); if ($reflection->hasMethod('__construct') === false) { return true; } $constructor = $reflection->getMethod('__construct'); if ($constructor->isPublic() === false) { throw new provider\object\exceptions\privateConstructor('Could not instanciate an object from ' . $class . ' because ' . $class . '::__construct() is private'); } if ($constructor->getNumberOfRequiredParameters() > 0) { throw new provider\object\exceptions\mandatoryArgument('Could not instanciate an object from ' . $class . ' because ' . $class . '::__construct() has at least one mandatory argument'); } return true; }