Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Di / Definition / Builder / InjectionMethod.php
blob41e6f242d45914b77f9d99efd272df3a78c5cd2c
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Di\Definition\Builder;
12 use Zend\Di\Di;
14 /**
15 * Definitions for an injection endpoint method
17 class InjectionMethod
19 /**
20 * @var string|null
22 protected $name = null;
24 /**
25 * @var array
27 protected $parameters = array();
29 /**
30 * @param string|null $name
31 * @return self
33 public function setName($name)
35 $this->name = $name;
37 return $this;
40 /**
41 * @return null|string
43 public function getName()
45 return $this->name;
48 /**
49 * @param string $name
50 * @param string|null $class
51 * @param mixed|null $isRequired
52 * @param mixed|null $default
53 * @return InjectionMethod
55 public function addParameter($name, $class = null, $isRequired = null, $default = null)
57 $this->parameters[] = array(
58 $name,
59 $class,
60 self::detectMethodRequirement($isRequired),
61 $default,
64 return $this;
67 /**
68 * @return array
70 public function getParameters()
72 return $this->parameters;
75 /**
77 * @param mixed $requirement
78 * @return int
80 public static function detectMethodRequirement($requirement)
82 if (is_bool($requirement)) {
83 return $requirement ? Di::METHOD_IS_REQUIRED : Di::METHOD_IS_OPTIONAL;
86 if (null === $requirement) {
87 //This is mismatch to ClassDefinition::addMethod is it ok ? is optional?
88 return Di::METHOD_IS_REQUIRED;
91 if (is_int($requirement)) {
92 return $requirement;
95 if (is_string($requirement)) {
96 switch (strtolower($requirement)) {
97 default:
98 case "require":
99 case "required":
100 return Di::METHOD_IS_REQUIRED;
101 break;
102 case "aware":
103 return Di::METHOD_IS_AWARE;
104 break;
105 case "optional":
106 return Di::METHOD_IS_OPTIONAL;
107 break;
108 case "constructor":
109 return Di::MEHTOD_IS_CONSTRUCTOR;
110 break;
111 case "instantiator":
112 return Di::METHOD_IS_INSTANTIATOR;
113 break;
114 case "eager":
115 return Di::METHOD_IS_EAGER;
116 break;
119 return 0;