Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "workivate/feature-keys",
"license": "MIT",
"description": "Feature Keys Domain Framework",
"version": "1.0.8",
"version": "1.0.9",
"require": {
"php": "^7.0"
},
Expand Down
26 changes: 3 additions & 23 deletions src/FeatureAccess/FeatureAccessConfigIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

namespace FeatureKeys\FeatureAccess;

use FeatureKeys\FeatureConfig\IteratorTrait;

abstract class FeatureAccessConfigIterator implements \Iterator
{
private $index = 0;

private $config = [];
use IteratorTrait;

protected function add(FeatureAccessConfigElement $configElement): void
{
Expand All @@ -18,24 +18,4 @@ public function current(): FeatureAccessConfigElement
{
return $this->config[$this->index];
}

public function next(): void
{
++$this->index;
}

public function key(): int
{
return $this->index;
}

public function valid(): bool
{
return isset($this->config[$this->index]);
}

public function rewind(): void
{
$this->index = 0;
}
}
24 changes: 1 addition & 23 deletions src/FeatureConfig/FeatureClassNameIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

abstract class FeatureClassNameIterator implements \Iterator
{
private $index = 0;

private $config = [];
use IteratorTrait;

public function add(ClassName $configElement): void
{
Expand All @@ -18,24 +16,4 @@ public function current(): ClassName
{
return $this->config[$this->index];
}

public function next(): void
{
++$this->index;
}

public function key(): int
{
return $this->index;
}

public function valid(): bool
{
return isset($this->config[$this->index]);
}

public function rewind(): void
{
$this->index = 0;
}
}
31 changes: 31 additions & 0 deletions src/FeatureConfig/IteratorTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);

namespace FeatureKeys\FeatureConfig;

trait IteratorTrait
{
private $index = 0;

private $config = [];

public function next(): void
{
++$this->index;
}

public function key(): int
{
return $this->index;
}

public function valid(): bool
{
return isset($this->config[$this->index]);
}

public function rewind(): void
{
$this->index = 0;
}
}
4 changes: 1 addition & 3 deletions src/FeatureOverride/FeatureOverrideContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ public function set(FeatureOverride $featureOverride): void

public function get(string $featureOverrideName): FeatureOverride
{
if (!$this->has($featureOverrideName)) {
throw FeatureOverrideContainerException::overrideNotFound($featureOverrideName);
}
foreach ($this->overrides as $override) {
if ($override::getName() !== $featureOverrideName) {
continue;
}
return $override;
}
throw FeatureOverrideContainerException::overrideNotFound($featureOverrideName);
}

public function has(string $featureOverrideName): bool
Expand Down
1 change: 1 addition & 0 deletions src/FeatureOverride/FeatureOverrideContainerHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ public static function unsetAfter(FeatureOverrideContainer $container, string $l
return $hydratedContainer;
}
}
throw new \LogicException("$lastOverrideName override is not present in the container");
}
}