silverstripe-framework/src/Core/Injector/InjectionCreator.php

24 lines
439 B
PHP
Raw Normal View History

<?php
namespace SilverStripe\Core\Injector;
use ReflectionClass;
/**
* A class for creating new objects by the injector.
*/
2016-11-29 00:31:16 +01:00
class InjectionCreator implements Factory
{
2016-11-29 00:31:16 +01:00
public function create($class, array $params = array())
{
$reflector = new ReflectionClass($class);
2016-11-29 00:31:16 +01:00
if (count($params)) {
return $reflector->newInstanceArgs($params);
}
2016-11-29 00:31:16 +01:00
return $reflector->newInstance();
}
}