get() public method

Returns the value of the given property.
public get ( string $property, mixed $default = null ) : mixed
$property string Property name.
$default mixed Default value to be returned in case the property doesn't exists.
return mixed The property value, or the result of the closure execution if property is a closure, or $default.
Esempio n. 1
0
 /**
  *	Constructor.
  *
  *	@param array $configuration Dependency injection configuration.
  */
 public function __construct(array $configuration = [])
 {
     $this->_Container = new StandardContainer($configuration);
     $this->_Http = $this->_Container->get('Http');
     $this->_Crawler = $this->_Container->get('Crawler');
     $this->_Extractor = $this->_Container->get('Extractor');
     $this->_Replacer = $this->_Container->get('Replacer');
 }
 /**
  *	Finds providers of the given url.
  *
  *	@todo Use PHP generators to yield providers.
  *	@param string $url An url which may be extracted.
  *	@return array An array of Essence\Provider.
  */
 public function providers($url)
 {
     $filters = $this->_Container->get('filters');
     foreach ($filters as $name => $filter) {
         if ($this->_matches($filter, $url)) {
             (yield $this->_Container->get($name));
         }
     }
 }
Esempio n. 3
0
 /**
  *	Lazy loads a provider given its name and configuration.
  *
  *	@param string $name Name.
  *	@param string $config Configuration.
  *	@return Provider Instance.
  */
 protected function _provider($name, $config)
 {
     if (!isset($this->_providers[$name])) {
         $class = $config['class'];
         $Provider = $this->_Container->has($class) ? $this->_Container->get($class) : new $class();
         $Provider->configure($config);
         $this->_providers[$name] = $Provider;
     }
     return $this->_providers[$name];
 }
Esempio n. 4
0
 /**
  *	Constructs a provider given its configuration.
  *
  *	@param string $config Configuration.
  *	@return Provider Instance.
  */
 protected function _buildProvider($config)
 {
     $name = $config['class'];
     if (!$this->_Container->has($name)) {
         throw new Exception("The '{$name}' provider is not configured.");
     }
     $Provider = $this->_Container->get($name);
     $Provider->configure($config);
     return $Provider;
 }