JordanRL/Fermat

View on GitHub

Showing 50 of 52 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public function add(MatrixInterface $value): static
{
if ($this->getRowCount() !== $value->getRowCount() || $this->getColumnCount() !== $value->getColumnCount()) {
throw new IntegrityConstraint(
'Matrices must be the same size in order to be added.',
Severity: Major
Found in src/Samsara/Fermat/LinearAlgebra/Types/Matrix.php and 1 other location - About 3 hrs to fix
src/Samsara/Fermat/LinearAlgebra/Types/Matrix.php on lines 322..346

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public function subtract(MatrixInterface $value): static
{
if ($this->getRowCount() !== $value->getRowCount() || $this->getColumnCount() !== $value->getColumnCount()) {
throw new IntegrityConstraint(
'Matrices must be the same size in order to be subtracted.',
Severity: Major
Found in src/Samsara/Fermat/LinearAlgebra/Types/Matrix.php and 1 other location - About 3 hrs to fix
src/Samsara/Fermat/LinearAlgebra/Types/Matrix.php on lines 126..150

The class Decimal has an overall complexity of 52 which is very high. The configured complexity threshold is 50.
Open

abstract class Decimal extends Number
{
 
protected NumberBase $base;
 
 

The class Matrix has an overall complexity of 50 which is very high. The configured complexity threshold is 50.
Open

abstract class Matrix implements MatrixInterface
{
public const MODE_ROWS_INPUT = 'rows';
public const MODE_COLUMNS_INPUT = 'columns';
 
 

The class NumberCollection has 29 public methods. Consider refactoring NumberCollection to keep number of public methods under 25.
Open

class NumberCollection implements NumberCollectionInterface, ArrayAccess, IteratorAggregate
{
 
/**
* @var Vector

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public function subtract(
string|int|float|Decimal|Fraction|ComplexNumber $num
): MutableDecimal|ImmutableDecimal|MutableComplexNumber|ImmutableComplexNumber|MutableFraction|ImmutableFraction|static
{
if (
src/Samsara/Fermat/Core/Types/Traits/SimpleArithmeticTrait.php on lines 47..66

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public function add(
string|int|float|Decimal|Fraction|ComplexNumber $num
): MutableDecimal|ImmutableDecimal|MutableComplexNumber|ImmutableComplexNumber|MutableFraction|ImmutableFraction|static
{
if (
src/Samsara/Fermat/Core/Types/Traits/SimpleArithmeticTrait.php on lines 250..269

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public static function onesMatrix(string $type, int $rows, int $columns): MatrixInterface
{
$matrixData = [];
 
for ($i = 0; $i < $rows; $i++) {
Severity: Major
Found in src/Samsara/Fermat/LinearAlgebra/Matrices.php and 1 other location - About 2 hrs to fix
src/Samsara/Fermat/LinearAlgebra/Matrices.php on lines 67..79

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public static function zeroMatrix(string $type, int $rows, int $columns): MatrixInterface
{
$matrixData = [];
 
for ($i = 0; $i < $rows; $i++) {
Severity: Major
Found in src/Samsara/Fermat/LinearAlgebra/Matrices.php and 1 other location - About 2 hrs to fix
src/Samsara/Fermat/LinearAlgebra/Matrices.php on lines 53..65

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public function unshiftRow(NumberCollection $row): static
{
if ($row->count() !== $this->numColumns) {
throw new IntegrityConstraint(
'The members of a new row must match the number of columns in a matrix.',
src/Samsara/Fermat/LinearAlgebra/Types/Traits/Matrix/DirectAccessTrait.php on lines 121..140

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public function unshiftColumn(NumberCollection $column): static
{
if ($column->count() !== $this->numRows) {
throw new IntegrityConstraint(
'The members of a new column must match the number of rows in a matrix.',
src/Samsara/Fermat/LinearAlgebra/Types/Traits/Matrix/DirectAccessTrait.php on lines 148..167

Similar blocks of code found in 3 locations. Consider refactoring.
Open

protected function multiplySelector(Decimal $num): string
{
$calcMode = $this->getResolvedMode();
if ($calcMode == CalcMode::Auto) {
$value = $this->multiplyGMP($num);
src/Samsara/Fermat/Core/Types/Base/Traits/ArithmeticSelectionTrait.php on lines 29..46
src/Samsara/Fermat/Core/Types/Base/Traits/ArithmeticSelectionTrait.php on lines 219..236

Similar blocks of code found in 3 locations. Consider refactoring.
Open

protected function addSelector(Decimal $num): string
{
$calcMode = $this->getResolvedMode();
if ($calcMode == CalcMode::Auto) {
$value = $this->addGMP($num);
src/Samsara/Fermat/Core/Types/Base/Traits/ArithmeticSelectionTrait.php on lines 133..150
src/Samsara/Fermat/Core/Types/Base/Traits/ArithmeticSelectionTrait.php on lines 219..236

Similar blocks of code found in 3 locations. Consider refactoring.
Open

protected function subtractSelector(Decimal $num): string
{
$calcMode = $this->getResolvedMode();
if ($calcMode == CalcMode::Auto) {
$value = $this->subtractGMP($num);
src/Samsara/Fermat/Core/Types/Base/Traits/ArithmeticSelectionTrait.php on lines 29..46
src/Samsara/Fermat/Core/Types/Base/Traits/ArithmeticSelectionTrait.php on lines 133..150

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public function pushColumn(NumberCollection $column): static
{
if ($column->count() !== $this->numRows) {
throw new IntegrityConstraint(
'The members of a new column must match the number of rows in a matrix.',
src/Samsara/Fermat/LinearAlgebra/Types/Traits/Matrix/DirectAccessTrait.php on lines 70..89

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public function pushRow(NumberCollection $row): static
{
if ($row->count() !== $this->numColumns) {
throw new IntegrityConstraint(
'The members of a new row must match the number of columns in a matrix.',
src/Samsara/Fermat/LinearAlgebra/Types/Traits/Matrix/DirectAccessTrait.php on lines 43..62

Similar blocks of code found in 3 locations. Consider refactoring.
Open

public function exp(?int $scale = null, bool $round = true): Decimal
{
$finalScale = $scale ?? $this->getScale();
 
$answer = $this->expSelector($scale);
Severity: Major
Found in src/Samsara/Fermat/Core/Types/Traits/SimpleLogTrait.php and 2 other locations - About 1 hr to fix
src/Samsara/Fermat/Core/Types/Traits/SimpleLogTrait.php on lines 56..69
src/Samsara/Fermat/Core/Types/Traits/SimpleLogTrait.php on lines 80..93

Similar blocks of code found in 3 locations. Consider refactoring.
Open

public function ln(?int $scale = null, bool $round = true): Decimal
{
$finalScale = $scale ?? $this->getScale();
 
$answer = $this->lnSelector($scale);
Severity: Major
Found in src/Samsara/Fermat/Core/Types/Traits/SimpleLogTrait.php and 2 other locations - About 1 hr to fix
src/Samsara/Fermat/Core/Types/Traits/SimpleLogTrait.php on lines 32..45
src/Samsara/Fermat/Core/Types/Traits/SimpleLogTrait.php on lines 80..93

Similar blocks of code found in 3 locations. Consider refactoring.
Open

public function log10(?int $scale = null, bool $round = true): Decimal
{
$finalScale = $scale ?? $this->getScale();
 
$answer = $this->log10Selector($scale);
Severity: Major
Found in src/Samsara/Fermat/Core/Types/Traits/SimpleLogTrait.php and 2 other locations - About 1 hr to fix
src/Samsara/Fermat/Core/Types/Traits/SimpleLogTrait.php on lines 32..45
src/Samsara/Fermat/Core/Types/Traits/SimpleLogTrait.php on lines 56..69

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<?php
 
namespace Samsara\Fermat\Core\Provider\RoundingModeAdapters\Modes;
 
/**
src/Samsara/Fermat/Core/Provider/RoundingModeAdapters/Modes/HalfEvenAdapter.php on lines 1..25
Severity
Category
Status
Source
Language