From a3503828302f46a79e8bbcb7e0b37066cd01fbf5 Mon Sep 17 00:00:00 2001 From: Rick Kuipers Date: Sun, 9 Aug 2015 18:03:09 +0200 Subject: [PATCH] Reduce complexity in detector --- src/PhpAssumptions/Detector.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/PhpAssumptions/Detector.php b/src/PhpAssumptions/Detector.php index f47bfa1..66cacfe 100644 --- a/src/PhpAssumptions/Detector.php +++ b/src/PhpAssumptions/Detector.php @@ -13,27 +13,25 @@ class Detector */ public function scan(Node $node) { + $result = false; + if ($node instanceof Expr\BinaryOp\NotIdentical || $node instanceof Expr\BinaryOp\NotEqual || $node instanceof Expr\BinaryOp\Equal ) { if ($this->bidirectionalCheck($node, Expr\Variable::class, Expr\ConstFetch::class)) { - return true; - } - - if (!$node instanceof Expr\BinaryOp\NotIdentical + $result = true; + } elseif (!$node instanceof Expr\BinaryOp\NotIdentical && $this->bidirectionalCheck($node, Expr\Variable::class, Node\Scalar::class) ) { - return true; + $result = true; } - } - - if (($node instanceof Expr\BooleanNot && $node->expr instanceof Expr\Variable) + } elseif (($node instanceof Expr\BooleanNot && $node->expr instanceof Expr\Variable) || property_exists($node, 'cond') && $node->cond instanceof Expr\Variable ) { - return true; + $result = true; } - return false; + return $result; } /**