/usr/share/doc/php-horde-injector/examples/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 | <?php
/**
* Demonstrates how to use the default implementation binder with Horde_Injector.
*
* 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';
interface Person
{
public function __toString();
}
class World implements Person
{
public function __toString()
{
return 'World';
}
}
interface Greeter
{
public function greet();
}
class Hello implements Greeter
{
public function __construct(Person $somebody)
{
$this->somebody = $somebody;
}
public function greet()
{
print 'Hello ' . $this->somebody;
}
}
$a = new Horde_Injector(new Horde_Injector_TopLevel());
$a->bindImplementation('Person', 'World');
$a->bindImplementation('Greeter', 'Hello');
$a->getInstance('Greeter')->greet();
|