Exemplo n.º 1
0
 public function isValid(Matrix $matrix)
 {
     $rowsSize = array_map(function ($row) {
         return count($row);
     }, $matrix->toArray());
     return count($rowsSize) > 0 && count(array_keys($rowsSize, $rowsSize[0])) == count($rowsSize);
 }
Exemplo n.º 2
0
 protected function traverseRow(Matrix $matrix, $rotatedMatrix, $rowIndex)
 {
     for ($columnIndex = 0, $width = $matrix->getWidth(); $columnIndex < $width; $columnIndex++) {
         if (!isset($rotatedMatrix[$rowIndex]) || !isset($rotatedMatrix[$columnIndex])) {
             $rotatedMatrix[$columnIndex] = [];
         }
         $rotatedMatrix[$columnIndex] = $this->addValueToRow($rotatedMatrix[$columnIndex], $this->getMatrixValue($matrix, $rowIndex, $columnIndex));
     }
     return $rotatedMatrix;
 }
Exemplo n.º 3
0
 protected function getMatrixValue(Matrix $matrix, $rowIndex, $columnIndex)
 {
     return $matrix->getValue($rowIndex, $columnIndex);
 }