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
10 namespace Zend\Di\Definition\Builder
;
15 * Definitions for an injection endpoint method
22 protected $name = null;
27 protected $parameters = array();
30 * @param string|null $name
33 public function setName($name)
43 public function getName()
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(
60 self
::detectMethodRequirement($isRequired),
70 public function getParameters()
72 return $this->parameters
;
77 * @param mixed $requirement
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)) {
95 if (is_string($requirement)) {
96 switch (strtolower($requirement)) {
100 return Di
::METHOD_IS_REQUIRED
;
103 return Di
::METHOD_IS_AWARE
;
106 return Di
::METHOD_IS_OPTIONAL
;
109 return Di
::MEHTOD_IS_CONSTRUCTOR
;
112 return Di
::METHOD_IS_INSTANTIATOR
;
115 return Di
::METHOD_IS_EAGER
;