public static function Spec::fromInfo in Little helpers 7.2
Create a new instance from a info array or string.
Parameters
string|array $info: This can be either an associative array with the following keys:
- class: The class that’s to be instantiated.
- constructor: The constructor method (see the property description).
- arguments: The constructor arguments (see the property description).
- calls: Additional method calls (see the property description).
… or a string. If this is a string it’s value is taken as the class name.
3 calls to Spec::fromInfo()
- Container::getSpec in src/
Services/ Container.php - Get a spec to for creating a new instance of the referenced class.
- SpecTest::testKwargs in tests/
Services/ SpecTest.php - Test passing keyword arguments in the spec.
- SpecTest::testKwargsException in tests/
Services/ SpecTest.php - Test exception when keyword argument is not defined.
File
- src/
Services/ Spec.php, line 68
Class
- Spec
- A class instantiation spec.
Namespace
Drupal\little_helpers\ServicesCode
public static function fromInfo($info) {
if (!is_array($info)) {
$info = [
'class' => $info,
];
}
$info += [
'constructor' => NULL,
'arguments' => [],
'calls' => [],
];
return new static($info['class'], $info['constructor'], $info['arguments'], $info['calls']);
}