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
{
private array $registryData;
public function __construct(RegistryInterface $registry)
$this->registryData = $registry->getData();
}
* @param string $input
* @return array
public function interpret(string $input): array
$input = explode(' ', $input);
foreach ($input as $value) {
if (is_numeric($value)) {
return $this->getDataFromRegistry($input, $this->registryData[$value - 1]);
throw new \InvalidArgumentException("No id specified");
* @param array $input
* @param AlbumInterface $item
private function getDataFromRegistry(array $input, AlbumInterface $item): array
$dataArray = [];
if ($value === "author") {
$dataArray["author"] = $item->getAuthor();
if ($value === "album") {
$dataArray["album"] = $item->getAlbum();
return $dataArray;