OpenXE/classes/Core/DependencyInjection/Definition/FactoryMethodDefinition.php

56 lines
1.1 KiB
PHP
Raw Normal View History

2021-05-21 08:49:41 +02:00
<?php
namespace Xentral\Core\DependencyInjection\Definition;
use Xentral\Core\DependencyInjection\Exception\InvalidArgumentException;
final class FactoryMethodDefinition
{
/** @var callable $callable */
private $callable;
/** @var bool $shared Share the same instance? */
private $shared;
/**
* @param callable $callable
* @param bool $shared
*
* @throws InvalidArgumentException
*/
public function __construct($callable, $shared = true)
{
if (!is_callable($callable, false)) {
/*
2022-10-14 14:18:26 +02:00
OpenXE-todo
unknown compatibility issue
commented out as hotfix
2021-05-21 08:49:41 +02:00
throw new InvalidArgumentException(sprintf(
'Definition can\'t be created. "%s::%s" is not callable.', $callable[0], $callable[1]
));
*/
2021-05-21 08:49:41 +02:00
}
$this->callable = $callable;
$this->shared = (bool)$shared;
}
/**
* @return callable
*/
public function getCallable()
{
return $this->callable;
}
/**
* @return bool
*/
public function isShared()
{
return $this->shared;
}
}