for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PEIP\Service;
/*
* This file is part of the PEIP package.
* (c) 2009-2016 Timo Michna <timomichna/yahoo.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
* ServiceContainerBuilder
* @author Timo Michna <timomichna/yahoo.de>
* @package PEIP
* @subpackage service
* @extends \PEIP\Data\InternalStoreAbstract
use PEIP\Factory\DedicatedFactory;
class ServiceContainerBuilder extends \PEIP\Data\InternalStoreAbstract
{
/**
* @param $key
* @param $factory
* @return
public function setFactory($key, DedicatedFactory $factory)
$this->setInternalValue($key, $factory);
}
public function getFactory($key)
$this->getInternalValue($key);
public function hasFactory($key)
$this->hasInternalValue($key);
public function deleteFactory($key)
$this->deleteInternalValue($key);
public function getService($key)
return isset($this->services[$key]) ? $this->services[$key] : $this->services[$key] = $this->getFactory($key)->build();
services
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
build
$this->getFactory($key)
null
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.
public function buildService($key)
return $this->getFactory($key)->build();
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: