Source of file InjectionMethod.php
Size: 2,883 Bytes - Last Modified: 2014-03-12T23:21:18+01:00
/home/theseer/Downloads/ZendFramework-2.3.0/library/Zend/Di/Definition/Builder/InjectionMethod.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 | <?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ namespace Zend\Di\Definition\Builder; use Zend\Di\Di; /** * Definitions for an injection endpoint method */ class InjectionMethod { /** * @var string|null */ protected $name = null; /** * @var array */ protected $parameters = array(); /** * @param string|null $name * @return self */ public function setName($name) { $this->name = $name; return $this; } /** * @return null|string */ public function getName() { return $this->name; } /** * @param string $name * @param string|null $class * @param mixed|null $isRequired * @param mixed|null $default * @return InjectionMethod */ public function addParameter($name, $class = null, $isRequired = null, $default = null) { $this->parameters[] = array( $name, $class, self::detectMethodRequirement($isRequired), $default, ); return $this; } /** * @return array */ public function getParameters() { return $this->parameters; } /** * * @param mixed $requirement * @return int */ public static function detectMethodRequirement($requirement) { if (is_bool($requirement)) { return $requirement ? Di::METHOD_IS_REQUIRED : Di::METHOD_IS_OPTIONAL; } if (null === $requirement) { //This is mismatch to ClassDefinition::addMethod is it ok ? is optional? return Di::METHOD_IS_REQUIRED; } if (is_int($requirement)) { return $requirement; } if (is_string($requirement)) { switch (strtolower($requirement)) { default: case "require": case "required": return Di::METHOD_IS_REQUIRED; break; case "aware": return Di::METHOD_IS_AWARE; break; case "optional": return Di::METHOD_IS_OPTIONAL; break; case "constructor": return Di::MEHTOD_IS_CONSTRUCTOR; break; case "instantiator": return Di::METHOD_IS_INSTANTIATOR; break; case "eager": return Di::METHOD_IS_EAGER; break; } } return 0; } } |