@@ -73,7 +73,7 @@ protected function isLiteralValid(array $literal)
7373 foreach ($ literal as $ row ) {
7474 $ thisRow = count ($ row );
7575
76- if ($ lastRow !== false && $ lastRow != $ thisRow ) {
76+ if ($ lastRow !== false && $ lastRow !== $ thisRow ) {
7777 return false ;
7878 }
7979
@@ -95,7 +95,7 @@ public static function identity($size)
9595 $ literal [] = [];
9696
9797 for ($ j = 0 ; $ j < $ size ; ++$ j ) {
98- $ literal [$ i ][] = ($ i == $ j ) ? 1 : 0 ;
98+ $ literal [$ i ][] = ($ i === $ j ) ? 1 : 0 ;
9999 }
100100 }
101101
@@ -127,7 +127,7 @@ public function add($value)
127127 */
128128 public function addMatrix (Matrix $ value )
129129 {
130- if ($ this ->getRowCount () != $ value ->getRowCount () || $ this ->getColumnCount () != $ value ->getColumnCount ()) {
130+ if ($ this ->getRowCount () !== $ value ->getRowCount () || $ this ->getColumnCount () != = $ value ->getColumnCount ()) {
131131 throw new MatrixException ('Cannot add two matrices of different size. ' );
132132 }
133133
@@ -195,15 +195,15 @@ public function adjoint()
195195 throw new MatrixException ('Adjoints can only be called on square matrices: ' . print_r ($ this ->internal , true ));
196196 }
197197
198- return $ this ->inverse ()->multiply ($ this ->determinant ());
198+ return $ this ->inverse ()->multiplyScalar ($ this ->determinant ());
199199 }
200200
201201 /**
202202 * @return boolean
203203 */
204204 public function isSquare ()
205205 {
206- return $ this ->getRowCount () == $ this ->getColumnCount ();
206+ return $ this ->getRowCount () === $ this ->getColumnCount ();
207207 }
208208
209209 /**
@@ -231,13 +231,13 @@ public function multiply($value)
231231 */
232232 public function multiplyMatrix (Matrix $ value )
233233 {
234- if ($ this ->getColumnCount () != $ value ->rowCount ) {
234+ if ($ this ->getColumnCount () !== $ value ->getRowCount () ) {
235235 throw new MatrixException ('Cannot multiply matrices of these sizes. ' );
236236 }
237237
238238 $ literal = [];
239239
240- for ($ i = 0 ; $ i < $ this ->rowCount ; $ i ++) {
240+ for ($ i = 0 ; $ i < $ this ->getRowCount () ; $ i ++) {
241241 $ row = [];
242242
243243 for ($ j = 0 ; $ j < $ value ->columnCount ; $ j ++) {
@@ -277,7 +277,7 @@ public function inverse()
277277 throw new MatrixException ('Inverse can only be called on square matrices: ' . print_r ($ this ->internal , true ));
278278 }
279279
280- if ($ this ->determinant () == 0 ) {
280+ if ($ this ->determinant () === 0 ) {
281281 throw new MatrixException ('This matrix has a zero determinant and is therefore not invertable: ' . print_r ($ this ->internal , true ));
282282 }
283283
@@ -295,7 +295,7 @@ public function determinant()
295295 }
296296
297297 // Base case for a 1 by 1 matrix
298- if ($ this ->getRowCount () == 1 ) {
298+ if ($ this ->getRowCount () === 1 ) {
299299 return $ this ->get (0 , 0 );
300300 }
301301
@@ -323,8 +323,8 @@ public function isSymmetric()
323323 return false ;
324324 }
325325
326- for ($ i = 0 ; $ i < $ this ->getRowCount (); ++ $ i ) {
327- for ($ j = 0 ; $ j < $ this ->getColumnCount (); ++ $ j ) {
326+ for ($ i = 0 ; $ i < $ this ->getRowCount (); $ i ++ ) {
327+ for ($ j = 0 ; $ j < $ this ->getColumnCount (); $ j ++ ) {
328328 if ($ i == $ j ) {
329329 continue ;
330330 }
@@ -372,7 +372,7 @@ public function contatenateBottom(Matrix $other)
372372 */
373373 public function contatenateRight (Matrix $ other )
374374 {
375- if ($ this ->rowCount !== $ other ->getRowCount ()) {
375+ if ($ this ->getRowCount () !== $ other ->getRowCount ()) {
376376 throw new MatrixException (
377377 'Cannot concatenate matrices of incompatible size: '
378378 . print_r ($ this ->internal , true )
@@ -383,7 +383,7 @@ public function contatenateRight(Matrix $other)
383383
384384 $ concatenated = [];
385385
386- for ($ i = 0 ; $ i < $ this ->rowCount ; $ i ++) {
386+ for ($ i = 0 ; $ i < $ this ->getRowCount () ; $ i ++) {
387387 $ concatenated [] = array_merge ($ this ->internal [$ i ], $ other ->internal [$ i ]);
388388 }
389389
@@ -411,13 +411,13 @@ public function diagonal()
411411 */
412412 public function equals (Matrix $ matrixB )
413413 {
414- if ($ this ->rowCount != $ matrixB ->rowCount || $ this ->getColumnCount () != $ matrixB ->columnCount ) {
414+ if ($ this ->getRowCount () !== $ matrixB ->getRowCount () || $ this ->getColumnCount () !== $ matrixB ->getColumnCount () ) {
415415 return false ;
416416 }
417417
418- for ($ i = $ this ->rowCount ; $ i --;) {
418+ for ($ i = $ this ->getRowCount () ; $ i --;) {
419419 for ($ j = $ this ->getColumnCount (); $ j --;) {
420- if ($ this ->get ($ i , $ j ) != $ matrixB ->get ($ i , $ j )) {
420+ if ($ this ->get ($ i , $ j ) !== $ matrixB ->get ($ i , $ j )) {
421421 return false ;
422422 }
423423 }
@@ -484,7 +484,7 @@ public function subtract($value)
484484 */
485485 public function subtractMatrix (Matrix $ value )
486486 {
487- if ($ this ->rowCount != $ value ->rowCount || $ this ->getColumnCount () != $ value ->columnCount ) {
487+ if ($ this ->getRowCount () !== $ value ->getRowCount () || $ this ->getColumnCount () != = $ value ->columnCount ) {
488488 throw new MatrixException ('Cannot subtract two matrices of different size. ' );
489489 }
490490
@@ -610,7 +610,7 @@ public function getColumnCount()
610610 */
611611 public function getRowCount ()
612612 {
613- return $ this ->rowCount ;
613+ return $ this ->getRowCount () ;
614614 }
615615
616616 /**
0 commit comments