/usr/share/php/Horde/Injector/Binder/Implementation.php is in php-horde-injector 2.0.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | <?php
/**
* TODO
*
* @author Bob Mckee <bmckee@bywires.com>
* @author James Pepin <james@jamespepin.com>
* @category Horde
* @package Injector
*/
class Horde_Injector_Binder_Implementation implements Horde_Injector_Binder
{
/**
* TODO
*/
private $_implementation;
/**
* @var Horde_Injector_DependencyFinder
*/
private $_dependencyFinder;
/**
* TODO
*/
public function __construct($implementation,
Horde_Injector_DependencyFinder $finder = null)
{
$this->_implementation = $implementation;
$this->_dependencyFinder = is_null($finder)
? new Horde_Injector_DependencyFinder()
: $finder;
}
/**
* TODO
*
* @return TODO
*/
public function getImplementation()
{
return $this->_implementation;
}
/**
* TODO
*
* @return boolean Equality.
*/
public function equals(Horde_Injector_Binder $otherBinder)
{
return (($otherBinder instanceof Horde_Injector_Binder_Implementation) &&
($otherBinder->getImplementation() == $this->_implementation));
}
/**
* TODO
*/
public function create(Horde_Injector $injector)
{
try {
$reflectionClass = new ReflectionClass($this->_implementation);
} catch (ReflectionException $e) {
throw new Horde_Injector_Exception($e);
}
$this->_validateImplementation($reflectionClass);
return $this->_getInstance($injector, $reflectionClass);
}
/**
* TODO
*/
protected function _validateImplementation(ReflectionClass $reflectionClass)
{
if ($reflectionClass->isAbstract() || $reflectionClass->isInterface()) {
throw new Horde_Injector_Exception('Cannot bind interface or abstract class "' . $this->_implementation . '" to an interface.');
}
}
/**
* TODO
*/
protected function _getInstance(Horde_Injector $injector,
ReflectionClass $class)
{
return $class->getConstructor()
? $class->newInstanceArgs($this->_dependencyFinder->getMethodDependencies($injector, $class->getConstructor()))
: $class->newInstance();
}
}
|