| Total Complexity | 8 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | final class Set implements \JsonSerializable |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var \RemotelyLiving\Doorkeeper\Features\Feature[] |
||
| 11 | */ |
||
| 12 | private $features = []; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @param \RemotelyLiving\Doorkeeper\Features\Feature[] $features |
||
| 16 | */ |
||
| 17 | public function __construct(array $features = []) |
||
| 18 | { |
||
| 19 | foreach ($features as $feature) { |
||
| 20 | $this->pushFeature($feature); |
||
| 21 | } |
||
| 22 | } |
||
| 23 | |||
| 24 | public function pushFeature(Feature $feature): void |
||
| 27 | } |
||
| 28 | |||
| 29 | public function offsetExists(string $featureName): bool |
||
| 30 | { |
||
| 31 | return isset($this->features[$featureName]); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @return \RemotelyLiving\Doorkeeper\Features\Feature[] |
||
| 36 | */ |
||
| 37 | public function getFeatures(): array |
||
| 38 | { |
||
| 39 | return $this->features; |
||
| 40 | } |
||
| 41 | |||
| 42 | public function getFeatureByName(string $featureName): Feature |
||
| 43 | { |
||
| 44 | if (!$this->offsetExists($featureName)) { |
||
| 45 | throw new \OutOfBoundsException("Feature {$featureName} does not exist"); |
||
| 46 | } |
||
| 47 | |||
| 48 | return $this->features[$featureName]; |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @return array |
||
| 53 | */ |
||
| 54 | public function jsonSerialize(): array |
||
| 57 | } |
||
| 58 | } |
||
| 59 |