| Total Complexity | 7 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class RecentParameterMemory |
||
| 6 | { |
||
| 7 | private string $memoryFile; |
||
| 8 | |||
| 9 | private array $memories = []; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * @param string $memoryFile |
||
| 13 | */ |
||
| 14 | public function __construct(string $memoryFile) |
||
| 15 | { |
||
| 16 | $this->memoryFile = $memoryFile; |
||
| 17 | |||
| 18 | if (file_exists($memoryFile)) { |
||
| 19 | $this->memories = json_decode(file_get_contents($memoryFile), true); |
||
| 20 | } |
||
| 21 | } |
||
| 22 | |||
| 23 | public function addParameter(string $parameterIdentifier, string $value): void |
||
| 24 | { |
||
| 25 | $this->memories[$parameterIdentifier] = $value; |
||
| 26 | } |
||
| 27 | |||
| 28 | public function hasParameter(string $parameterIdentifier): bool |
||
| 31 | } |
||
| 32 | |||
| 33 | public function getParameter(string $parameterIdentifier): string |
||
| 34 | { |
||
| 35 | if (!$this->hasParameter($parameterIdentifier)) { |
||
| 36 | throw new \RuntimeException('No parameter with identifier "' . $parameterIdentifier . '" found. Please use hasParameter before using this method.'); |
||
| 37 | } |
||
| 38 | |||
| 39 | return $this->memories[$parameterIdentifier]; |
||
| 40 | } |
||
| 41 | |||
| 42 | public function dump(): void |
||
| 45 | } |
||
| 46 | } |
||
| 47 |