for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/**
* @author : Jagepard <[email protected]>
* @license https://mit-license.org/ MIT
*/
namespace Behavioral\Interpreter;
class Interpreter implements InterpreterInterface
{
* @var array
private $registry;
* @param AlbumInterface $item
public function addAlbumToRegistry(AlbumInterface $item): void
$this->registry[] = $item;
}
* @param string $input
public function interpret(string $input): void
$item = null;
$item
$input = explode(" ", $input);
foreach ($input as $value) {
if (is_numeric($value)) {
$this->getDataFromRegistry($input, $this->registry[$value - 1]);
* @param array $input
* @param $item
private function getDataFromRegistry(array $input, AlbumInterface $item): void
if ($value === "album") {
printf("%s ", $item->getName());
if ($value === "author") {
printf("%s", $item->getAuthor());
printf("%s", PHP_EOL);