Code Duplication    Length = 31-31 lines in 3 locations

src/PhpSpreadsheet/Shared/JAMA/Matrix.php 3 locations

@@ 815-845 (lines=31) @@
812
     *
813
     * @return Matrix Matrix Aij
814
     */
815
    public function arrayRightDivideEquals(...$args)
816
    {
817
        if (count($args) > 0) {
818
            $match = implode(',', array_map('gettype', $args));
819
820
            switch ($match) {
821
                case 'object':
822
                    if ($args[0] instanceof self) {
823
                        $M = $args[0];
824
                    } else {
825
                        throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_TYPE_EXCEPTION);
826
                    }
827
                    break;
828
                case 'array':
829
                    $M = new self($args[0]);
830
                    break;
831
                default:
832
                    throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
833
                    break;
834
            }
835
            $this->checkMatrixDimensions($M);
836
            for ($i = 0; $i < $this->m; ++$i) {
837
                for ($j = 0; $j < $this->n; ++$j) {
838
                    $this->A[$i][$j] = $this->A[$i][$j] / $M->get($i, $j);
839
                }
840
            }
841
842
            return $M;
843
        }
844
        throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
845
    }
846
847
    /**
848
     * arrayLeftDivide.
@@ 857-887 (lines=31) @@
854
     *
855
     * @return Matrix Division result
856
     */
857
    public function arrayLeftDivide(...$args)
858
    {
859
        if (count($args) > 0) {
860
            $match = implode(',', array_map('gettype', $args));
861
862
            switch ($match) {
863
                case 'object':
864
                    if ($args[0] instanceof self) {
865
                        $M = $args[0];
866
                    } else {
867
                        throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_TYPE_EXCEPTION);
868
                    }
869
                    break;
870
                case 'array':
871
                    $M = new self($args[0]);
872
                    break;
873
                default:
874
                    throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
875
                    break;
876
            }
877
            $this->checkMatrixDimensions($M);
878
            for ($i = 0; $i < $this->m; ++$i) {
879
                for ($j = 0; $j < $this->n; ++$j) {
880
                    $M->set($i, $j, $M->get($i, $j) / $this->A[$i][$j]);
881
                }
882
            }
883
884
            return $M;
885
        }
886
        throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
887
    }
888
889
    /**
890
     * arrayLeftDivideEquals.
@@ 899-929 (lines=31) @@
896
     *
897
     * @return Matrix Matrix Aij
898
     */
899
    public function arrayLeftDivideEquals(...$args)
900
    {
901
        if (count($args) > 0) {
902
            $match = implode(',', array_map('gettype', $args));
903
904
            switch ($match) {
905
                case 'object':
906
                    if ($args[0] instanceof self) {
907
                        $M = $args[0];
908
                    } else {
909
                        throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::ARGUMENT_TYPE_EXCEPTION);
910
                    }
911
                    break;
912
                case 'array':
913
                    $M = new self($args[0]);
914
                    break;
915
                default:
916
                    throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
917
                    break;
918
            }
919
            $this->checkMatrixDimensions($M);
920
            for ($i = 0; $i < $this->m; ++$i) {
921
                for ($j = 0; $j < $this->n; ++$j) {
922
                    $this->A[$i][$j] = $M->get($i, $j) / $this->A[$i][$j];
923
                }
924
            }
925
926
            return $M;
927
        }
928
        throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
929
    }
930
931
    /**
932
     * times.