/usr/share/doc/php-horde-injector/examples/binder.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 | <?php
/**
* Demonstrates how we register binders so that the instances get created only
* when actually accessing the instance.
*
* PHP version 5
*
* @category Horde
* @package Injector
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/bsd BSD
* @link http://pear.horde.org/index.php?package=Injector
*/
require 'Horde/Autoloader.php';
/**
* A dummy binder.
*
* @category Horde
* @package Injector
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/bsd BSD
* @link http://pear.horde.org/index.php?package=Injector
*/
class Binder implements Horde_Injector_Binder
{
/**
* Create an instance.
*
* @param Horde_Injector $injector The injector should provide all required
* dependencies for creating the instance.
*
* @return mixed The concrete instance.
*/
public function create(Horde_Injector $injector)
{
return 'constructed';
}
/**
* Determine if one binder equals another binder
*
* @param Horde_Injector_Binder $binder The binder to compare against $this
*
* @return bool true if they are equal, or false if they are not equal
*/
public function equals(Horde_Injector_Binder $binder)
{
return false;
}
}
$a = new Horde_Injector(new Horde_Injector_TopLevel());
$a->addBinder('constructed', new Binder());
var_dump($a->getInstance('constructed'));
|