Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
18 / 18 |
Bundles | |
100.00% |
1 / 1 |
|
100.00% |
5 / 5 |
9 | |
100.00% |
18 / 18 |
__construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
bundles | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
get | |
100.00% |
1 / 1 |
3 | |
100.00% |
6 / 6 |
|||
requireBundles | |
100.00% |
1 / 1 |
3 | |
100.00% |
8 / 8 |
|||
buildBundles | |
100.00% |
1 / 1 |
1 |
<?php | |
namespace PHPixie\BundleFramework; | |
abstract class Bundles implements \PHPixie\Bundles\Registry | |
{ | |
protected $builder; | |
protected $bundles; | |
public function __construct($builder) | |
{ | |
$this->builder = $builder; | |
} | |
public function bundles() | |
{ | |
$this->requireBundles(); | |
return $this->bundles; | |
} | |
public function get($name, $isRequired = true) | |
{ | |
$this->requireBundles(); | |
if(array_key_exists($name, $this->bundles)) { | |
return $this->bundles[$name]; | |
} | |
if(!$isRequired) { | |
return null; | |
} | |
throw new \PHPixie\BundleFramework\Exception("Bundle '$name' does not exist"); | |
} | |
protected function requireBundles() | |
{ | |
if($this->bundles !== null) { | |
return; | |
} | |
$bundles = array(); | |
foreach($this->buildBundles() as $bundle) { | |
$bundles[$bundle->name()] = $bundle; | |
} | |
$this->bundles = $bundles; | |
} | |
abstract protected function buildBundles(); | |
} |