Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
17 / 17 |
Bundle | |
100.00% |
1 / 1 |
|
100.00% |
7 / 7 |
10 | |
100.00% |
17 / 17 |
__construct($name = null) | |
100.00% |
1 / 1 |
2 | |
100.00% |
3 / 3 |
|||
addApp($app) | |
100.00% |
1 / 1 |
1 | |
100.00% |
3 / 3 |
|||
addApps($apps) | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
getApps() | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
getName() | |
100.00% |
1 / 1 |
2 | |
100.00% |
3 / 3 |
|||
setName($name) | |
100.00% |
1 / 1 |
2 | |
100.00% |
4 / 4 |
|||
getIterableCollection() | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
<?php | |
namespace TriNetAssess; | |
/** | |
* Class Bundle | |
* | |
* @package TriNetAssess | |
*/ | |
class Bundle extends IterableCollection | |
{ | |
/** | |
* The Apps applied to the Bundle | |
* | |
* @var App[] $apps | |
*/ | |
protected $apps = []; | |
/** | |
* The Bundle's name | |
* | |
* @var string $name | |
*/ | |
protected $name; | |
/** | |
* Company constructor. | |
* | |
* @param string|null $name the Bundle's name | |
* | |
* @throws \DomainException | |
*/ | |
public function __construct($name = null) | |
{ | |
if (null !== $name) { | |
$this->setName($name); | |
} | |
} | |
/** | |
* Add an App to the Bundle | |
* | |
* @param App $app the App to apply to the Bundle | |
* | |
* @return App[] the Apps applied to the Bundle | |
*/ | |
public function addApp($app) | |
{ | |
$this->apps[] = $app; | |
$this->apps = array_map('unserialize', array_unique(array_map('serialize', $this->apps))); | |
return $this->apps; | |
} | |
/** | |
* Add multiple Apps to the Bundle | |
* | |
* @param App[] $apps the Apps to apply to the Bundle | |
* | |
* @return App[] the Apps applied to the Bundle | |
*/ | |
public function addApps($apps) | |
{ | |
array_walk($apps, [$this, 'addApp']); | |
return $this->apps; | |
} | |
/** | |
* Get the Apps applied to the Bundle | |
* | |
* @return App[] the Apps applied to the Bundle | |
*/ | |
public function getApps() | |
{ | |
return $this->apps; | |
} | |
/** | |
* Get the Bundle's name | |
* | |
* @return string the Bundle's name | |
* @throws \DomainException | |
*/ | |
public function getName() | |
{ | |
if (!is_string($this->name)) { | |
throw new \DomainException('Bundle name must be a string'); | |
} | |
return $this->name; | |
} | |
/** | |
* Set the Bundle's name | |
* | |
* @param string $name the Bundle's name | |
* | |
* @return string the Bundle's name | |
* @throws \DomainException | |
*/ | |
public function setName($name) | |
{ | |
if (!is_string($name)) { | |
throw new \DomainException('Bundle name must be a string'); | |
} | |
$this->name = $name; | |
return $this->name; | |
} | |
/** | |
* Returns the iterable collection | |
* | |
* @return array | |
*/ | |
protected function getIterableCollection() | |
{ | |
return $this->apps; | |
} |