src/GameOfLife/Field.php
/**
     * Calculates the number of living neighbor cells.
     *
     * @return int The number of living neighbor cells
     */
Calculates the number of living neighbor cells.
@return int The number of living neighbor cells
Calculates the number of living neighbor cells . @return int The number of living neighbor cells
public function numberOfLivingNeighbors(): int
    {
        $neighbors = $this->parentBoard->getNeighborsOfField($this);
        $numberOfLivingNeighbors = 0;
        foreach ($neighbors as $neighbor)
        {
            if ($neighbor->isAlive()) $numberOfLivingNeighbors++;
        }
        return $numberOfLivingNeighbors;
    }
public function numberOfLivingNeighbors ( ) : int { $ neighbors = $ this -> parentBoard -> getNeighborsOfField ( $ this ) ; $ numberOfLivingNeighbors = 0 ; foreach ( $ neighbors as $ neighbor ) { if ( $ neighbor -> isAlive ( ) ) $ numberOfLivingNeighbors ++ ; } return $ numberOfLivingNeighbors ; }
Calculates the number of living neighbor cells.
Calculates the number of living neighbor cells .
/** @var Field[] $neighbors */