Code Duplication    Length = 31-31 lines in 3 locations

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

@@ 848-878 (lines=31) @@
845
     *
846
     * @return Matrix Matrix Aij
847
     */
848
    public function arrayRightDivideEquals(...$args)
849
    {
850
        if (count($args) > 0) {
851
            $match = implode(',', array_map('gettype', $args));
852
853
            switch ($match) {
854
                case 'object':
855
                    if ($args[0] instanceof self) {
856
                        $M = $args[0];
857
                    } else {
858
                        throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
859
                    }
860
861
                    break;
862
                case 'array':
863
                    $M = new self($args[0]);
864
865
                    break;
866
                default:
867
                    throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
868
                    break;
869
            }
870
            $this->checkMatrixDimensions($M);
871
            for ($i = 0; $i < $this->m; ++$i) {
872
                for ($j = 0; $j < $this->n; ++$j) {
873
                    $this->A[$i][$j] = $this->A[$i][$j] / $M->get($i, $j);
874
                }
875
            }
876
877
            return $M;
878
        }
879
880
        throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
881
    }
@@ 893-923 (lines=31) @@
890
     *
891
     * @return Matrix Division result
892
     */
893
    public function arrayLeftDivide(...$args)
894
    {
895
        if (count($args) > 0) {
896
            $match = implode(',', array_map('gettype', $args));
897
898
            switch ($match) {
899
                case 'object':
900
                    if ($args[0] instanceof self) {
901
                        $M = $args[0];
902
                    } else {
903
                        throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
904
                    }
905
906
                    break;
907
                case 'array':
908
                    $M = new self($args[0]);
909
910
                    break;
911
                default:
912
                    throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
913
                    break;
914
            }
915
            $this->checkMatrixDimensions($M);
916
            for ($i = 0; $i < $this->m; ++$i) {
917
                for ($j = 0; $j < $this->n; ++$j) {
918
                    $M->set($i, $j, $M->get($i, $j) / $this->A[$i][$j]);
919
                }
920
            }
921
922
            return $M;
923
        }
924
925
        throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
926
    }
@@ 938-968 (lines=31) @@
935
     *
936
     * @return Matrix Matrix Aij
937
     */
938
    public function arrayLeftDivideEquals(...$args)
939
    {
940
        if (count($args) > 0) {
941
            $match = implode(',', array_map('gettype', $args));
942
943
            switch ($match) {
944
                case 'object':
945
                    if ($args[0] instanceof self) {
946
                        $M = $args[0];
947
                    } else {
948
                        throw new CalculationException(self::ARGUMENT_TYPE_EXCEPTION);
949
                    }
950
951
                    break;
952
                case 'array':
953
                    $M = new self($args[0]);
954
955
                    break;
956
                default:
957
                    throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
958
                    break;
959
            }
960
            $this->checkMatrixDimensions($M);
961
            for ($i = 0; $i < $this->m; ++$i) {
962
                for ($j = 0; $j < $this->n; ++$j) {
963
                    $this->A[$i][$j] = $M->get($i, $j) / $this->A[$i][$j];
964
                }
965
            }
966
967
            return $M;
968
        }
969
970
        throw new CalculationException(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
971
    }