for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/**
* @author : Korotkov Danila <[email protected]>
* @license https://mit-license.org/ MIT
*/
namespace Behavioral\Interpreter;
* Class Interpreter
* @package Behavioral\Interpreter
class Interpreter implements InterpreterInterface
{
* @var Item
protected $item;
* @var Depository
protected $depository;
* Interpreter constructor.
* @param Depository $depository
public function __construct(Depository $depository)
$this->depository = $depository;
}
* @param string $input
public function interpret(string $input): void
$input = explode(" ", $input);
foreach ($input as $value) {
if (is_numeric($value)) {
$item = $this->depository->getItems()[$value - 1];
if ($value == "album") {
printf("%s ", $item->getAlbum());
$item
if ($value == "author") {
printf("%s", $item->getAuthor());
printf("%s", PHP_EOL);