Showing 178 of 188 total issues
Method visitExpressionNode
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitExpressionNode(ExpressionNode $node)
{
$operator = $node->getOperator();
$left = $node->getLeft();
Function visitFunctionNode
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function visitFunctionNode(FunctionNode $node)
{
$inner = $node->getOperand()->accept($this);
$arg = $node->getOperand();
- Read upRead up
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"
Further reading
Method ifactor
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function ifactor($n)
{
// max_n = 2^31-1 = 2147483647
$d = 2;
Method visitExpressionNode
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitExpressionNode(ExpressionNode $node)
{
$operator = $node->getOperator();
$a = $node->getLeft()->accept($this);
Method visitFunctionNode
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitFunctionNode(FunctionNode $node)
{
$functionName = $node->getName();
$operand = $node->getOperand()->accept($this);
Function numericExponent
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function numericExponent($leftOperand, $rightOperand)
{
// 0^0 throws an exception
if ($this->isNumeric($leftOperand) && $this->isNumeric($rightOperand)) {
if ($leftOperand->getValue() == 0 && $rightOperand->getValue() == 0)
- Read upRead up
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"
Further reading
Method __construct
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function __construct($left, $operator = null, $right = null)
{
$this->left = $this->sanitize($left);
$this->operator = $operator;
$this->right = $this->sanitize($right);
Method fromFloat
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function fromFloat($float, $tolerance=1e-7)
{
if (is_string($float) && preg_match('~^\-?\d+([,|.]\d+)?$~', $float)) {
$float = floatval(str_replace(',','.',$float));
}
Method parenthesize
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parenthesize(Node $node, ExpressionNode $cutoff, $prepend = '', $conservative = false)
{
$text = $node->accept($this);
if ($node instanceof ExpressionNode) {
Method rpow
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function rpow($a, $b)
{
if ($b->getDenominator() == 1) {
$n = $b->getNumerator();
if ($n >= 0) {
Method handleExpression
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function handleExpression($node)
{
if ($node instanceof FunctionNode) throw new ParenthesisMismatchException($node->getOperator());
if ($node instanceof SubExpressionNode) throw new ParenthesisMismatchException($node->getOperator());
Method visitExpressionNode
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitExpressionNode(ExpressionNode $node)
{
$operator = $node->getOperator();
$leftValue = $node->getLeft()->accept($this);
Method visitExpressionNode
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitExpressionNode(ExpressionNode $node)
{
$operator = $node->getOperator();
$left = $node->getLeft();
$right = $node->getRight();
Method factory
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function factory(Token $token)
{
switch ($token->getType()) {
case TokenType::PosInt:
case TokenType::Integer:
Method rationalFactory
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function rationalFactory(Token $token)
{
switch ($token->getType()) {
case TokenType::PosInt:
case TokenType::Integer:
Method canFactorsInImplicitMultiplication
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function canFactorsInImplicitMultiplication($token1, $token2)
{
if ($token1 === null || $token2 === null) return false;
$check1 = (
Function visitExpressionNode
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function visitExpressionNode(ExpressionNode $node)
{
$operator = $node->getOperator();
$leftValue = $node->getLeft()->accept($this);
- Read upRead up
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"
Further reading
Function parse
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function parse($value, $normalize=true)
{
if ($value === '') return null;
if ($value === 'NAN') return new Rational(NAN, 1);
if ($value === 'INF') return new Rational(INF, 1);
- Read upRead up
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"
Further reading
Function numericFactors
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function numericFactors($leftOperand, $rightOperand)
{
if ($this->isNumeric($rightOperand) && $rightOperand->getValue() == 0) {
throw new DivisionByZeroException();
}
- Read upRead up
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"
Further reading
Function rpow
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function rpow($a, $b)
{
if ($b->getDenominator() == 1) {
$n = $b->getNumerator();
if ($n >= 0) {
- Read upRead up
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"