33    public const SIZE_SMALL = 2;
 
   34    public const SIZE_BIG = 3;
 
   36    private ?
int $startX = 
null;
 
   37    private ?
int $xLen = 
null;
 
   38    private ?
int $startY = 
null;
 
   39    private ?
int $yLen = 
null;
 
   41    public function __construct(
 
   42        private int $gridWidth
 
   44        parent::__construct($this->getGridWidth() ** 2);
 
   47    public function getGridWidth() : 
int{
 
   48        return $this->gridWidth;
 
   53        $this->seekRecipeBounds();
 
 
   56    private function seekRecipeBounds() : void{
 
   65        for($y = 0; $y < $this->gridWidth; ++$y){
 
   66            for($x = 0; $x < $this->gridWidth; ++$x){
 
   67                if(!$this->isSlotEmpty($y * $this->gridWidth + $x)){
 
   68                    $minX = min($minX, $x);
 
   69                    $maxX = max($maxX, $x);
 
   71                    $minY = min($minY, $y);
 
   72                    $maxY = max($maxY, $y);
 
   80            $this->startX = $minX;
 
   81            $this->xLen = $maxX - $minX + 1;
 
   82            $this->startY = $minY;
 
   83            $this->yLen = $maxY - $minY + 1;
 
   85            $this->startX = $this->xLen = $this->startY = $this->yLen = 
null;
 
   93        if($this->startX !== null && $this->startY !== null){
 
   94            return $this->getItem(($y + $this->startY) * $this->gridWidth + ($x + $this->startX));
 
   97        throw new \LogicException(
"No ingredients found in grid");
 
 
  104        return $this->xLen ?? 0;
 
 
  111        return $this->yLen ?? 0;