# chippyash/Math-Matrix

### Showing 52 of 183 total issues

#### Function `decompose` has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open

``````    public function decompose(NumericMatrix \$mA, \$extra = null)
{
\$this->assertParameterIsMatrix(\$extra, 'Parameter extra is not a matrix')
->assertMatrixIsNumeric(\$extra, 'Parameter extra is not a numeric matrix')
->assertMatrixIsSquare(\$mA,``````
Found in src/Chippyash/Math/Matrix/Decomposition/GaussJordanElimination.php - About 4 hrs to fix

# Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

### A method's cognitive complexity is based on a few simple rules:

• Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
• Code is considered more complex for each "break in the linear flow of the code"
• Code is considered more complex when "flow breaking structures are nested"

#### Function `createCorrectScalarType` has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open

``````    protected function createCorrectScalarType(NumericMatrix \$originalMatrix , \$scalar)
{
if (\$scalar instanceof NumericTypeInterface) {
if (\$originalMatrix instanceof RationalMatrix) {
return \$scalar->asRational();``````
Found in src/Chippyash/Math/Matrix/Traits/CreateCorrectScalarType.php - About 3 hrs to fix

# Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

### A method's cognitive complexity is based on a few simple rules:

• Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
• Code is considered more complex for each "break in the linear flow of the code"
• Code is considered more complex when "flow breaking structures are nested"

#### Function `LUDecomposition` has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open

``````    protected function LUDecomposition(NumericMatrix \$mA)
{
// Use a "left-looking", dot-product, Crout/Doolittle algorithm.
\$LU = \$mA->toArray();
\$m = \$this->rows = \$mA->rows();``````
Found in src/Chippyash/Math/Matrix/Decomposition/Lu.php - About 3 hrs to fix

# Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

### A method's cognitive complexity is based on a few simple rules:

• Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
• Code is considered more complex for each "break in the linear flow of the code"
• Code is considered more complex when "flow breaking structures are nested"

#### Function `createRational` has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open

``````    public static function createRational(array \$data)
{
foreach (\$data as &\$row) {
foreach (\$row as &\$item) {
if (!\$item instanceof RationalType) {``````
Found in src/Chippyash/Math/Matrix/MatrixFactory.php - About 2 hrs to fix

# Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

### A method's cognitive complexity is based on a few simple rules:

• Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
• Code is considered more complex for each "break in the linear flow of the code"
• Code is considered more complex when "flow breaking structures are nested"

#### Function `checkEntryEquality` has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open

``````    protected function checkEntryEquality(Matrix \$mB, \$strict)
{
if (\$strict) {
if (get_class(\$this) !== get_class(\$mB)) {
return false;``````
Found in src/Chippyash/Math/Matrix/NumericMatrix.php - About 2 hrs to fix

# Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

### A method's cognitive complexity is based on a few simple rules:

• Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
• Code is considered more complex for each "break in the linear flow of the code"
• Code is considered more complex when "flow breaking structures are nested"

#### Function `createComplex` has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open

``````    public static function createComplex(array \$data)
{
foreach (\$data as &\$row) {
foreach (\$row as &\$item) {
if (!\$item instanceof ComplexType) {``````
Found in src/Chippyash/Math/Matrix/MatrixFactory.php - About 2 hrs to fix

# Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

### A method's cognitive complexity is based on a few simple rules:

• Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
• Code is considered more complex for each "break in the linear flow of the code"
• Code is considered more complex when "flow breaking structures are nested"

#### Method `decompose` has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open

``````    public function decompose(NumericMatrix \$mA, \$extra = null)
{
\$this->assertParameterIsMatrix(\$extra, 'Parameter extra is not a matrix')
->assertMatrixIsNumeric(\$extra, 'Parameter extra is not a numeric matrix')
->assertMatrixIsSquare(\$mA,``````
Found in src/Chippyash/Math/Matrix/Decomposition/GaussJordanElimination.php - About 2 hrs to fix

#### Method `format` has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open

``````    public function format(Matrix \$mA, array \$options = array())
{
if (!\$mA instanceof NumericMatrix) {
throw new \InvalidArgumentException('Matrix is not NumericMatrix');
}``````
Found in src/Chippyash/Math/Matrix/Formatter/DirectedGraph.php - About 2 hrs to fix

#### Method `LUDecomposition` has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open

``````    protected function LUDecomposition(NumericMatrix \$mA)
{
// Use a "left-looking", dot-product, Crout/Doolittle algorithm.
\$LU = \$mA->toArray();
\$m = \$this->rows = \$mA->rows();``````
Found in src/Chippyash/Math/Matrix/Decomposition/Lu.php - About 2 hrs to fix

#### Method `createCorrectScalarType` has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open

``````    protected function createCorrectScalarType(NumericMatrix \$originalMatrix , \$scalar)
{
if (\$scalar instanceof NumericTypeInterface) {
if (\$originalMatrix instanceof RationalMatrix) {
return \$scalar->asRational();``````
Found in src/Chippyash/Math/Matrix/Traits/CreateCorrectScalarType.php - About 1 hr to fix

#### Method `__invoke` has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open

``````    public function __invoke()
{
//argument arbitrage
\$numArgs = func_num_args();
if (\$numArgs == 1) {``````
Found in src/Chippyash/Math/Matrix/NumericMatrix.php - About 1 hr to fix

#### Method `convertNumberToNumeric` has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open

``````    protected function convertNumberToNumeric(\$value)
{
switch(gettype(\$value)) {
case 'integer':
return TypeFactory::createInt(\$value);``````
Found in src/Chippyash/Math/Matrix/Traits/ConvertNumberToNumeric.php - About 1 hr to fix

#### Method `validateArguments` has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open

``````    protected function validateArguments(array \$args)
{
\$valA = new HasTypeMap([
'x' => 'integer'
]``````
Found in src/Chippyash/Math/Matrix/Special/Cauchy.php - About 1 hr to fix

#### Method `validateArguments` has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open

``````    protected function validateArguments(array \$args)
{
\$valA = new HasTypeMap([
'x' => 'integer'
]``````
Found in src/Chippyash/Math/Matrix/Special/Chebspec.php - About 1 hr to fix

#### Method `setLowerProduct` has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open

``````    protected function setLowerProduct(NumericMatrix \$mA)
{
\$m = \$this->LU->rows();
\$n = \$this->LU->columns();
\$LU = \$this->LU->toArray();``````
Found in src/Chippyash/Math/Matrix/Decomposition/Lu.php - About 1 hr to fix

#### Function `is` has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open

``````    public function is(Matrix \$mA)
{
if (!\$mA instanceof NumericMatrix) {
return false;
}``````
Found in src/Chippyash/Math/Matrix/Attribute/IsIdentity.php - About 1 hr to fix

# Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

### A method's cognitive complexity is based on a few simple rules:

• Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
• Code is considered more complex for each "break in the linear flow of the code"
• Code is considered more complex when "flow breaking structures are nested"

#### Method `setUpperProduct` has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open

``````    protected function setUpperProduct(NumericMatrix \$mA)
{
\$n = \$this->LU->columns();
\$LU = \$this->LU->toArray();
\$rcFactor = \$this->cols -\$this->rows;``````
Found in src/Chippyash/Math/Matrix/Decomposition/Lu.php - About 1 hr to fix

#### Avoid deeply nested control flow statements. Open

``````                        if (\$comp->eq(\$ipiv[\$k], \$zero())) {
\$absVal = \$dA[\$j][\$k]->abs();
if (\$comp->gt(\$absVal, \$big)) {
unset(\$big);
\$big = clone \$absVal;``````
Found in src/Chippyash/Math/Matrix/Decomposition/GaussJordanElimination.php - About 45 mins to fix

#### Function `toRational` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open

``````    protected function toRational(array \$dA)
{
foreach (\$dA as &\$row) {
foreach (\$row as &\$entry) {
if (\$entry instanceof NumericTypeInterface) {``````
Found in src/Chippyash/Math/Matrix/Formatter/AsciiNumeric.php - About 45 mins to fix

# Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

### A method's cognitive complexity is based on a few simple rules:

• Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
• Code is considered more complex for each "break in the linear flow of the code"
• Code is considered more complex when "flow breaking structures are nested"

#### Function `__invoke` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open

``````    public function __invoke()
{
//argument arbitrage
\$numArgs = func_num_args();
if (\$numArgs == 1) {``````
Found in src/Chippyash/Math/Matrix/NumericMatrix.php - About 45 mins to fix

# Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

### A method's cognitive complexity is based on a few simple rules:

• Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
• Code is considered more complex for each "break in the linear flow of the code"
• Code is considered more complex when "flow breaking structures are nested"