2016-03-08 10:24:26 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @version 1.0.0
|
|
|
|
* @package Detecting negative numbers
|
|
|
|
* @license GNU General Public License <http://www.gnu.org/copyleft/gpl.html>
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
|
|
|
|
// No direct access.
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Detecting negative numbers
|
|
|
|
**/
|
|
|
|
|
2019-04-04 11:53:29 +00:00
|
|
|
class SupportgroupsExpression
|
2016-03-08 10:24:26 +00:00
|
|
|
{
|
2019-04-04 11:53:29 +00:00
|
|
|
protected $expression;
|
|
|
|
protected $result;
|
2016-03-08 10:24:26 +00:00
|
|
|
|
2019-04-04 11:53:29 +00:00
|
|
|
public function __construct($expression)
|
2016-03-08 10:24:26 +00:00
|
|
|
{
|
2019-04-04 11:53:29 +00:00
|
|
|
$this->expression = $expression;
|
|
|
|
}
|
2016-03-08 10:24:26 +00:00
|
|
|
|
2019-04-04 11:53:29 +00:00
|
|
|
public function evaluate()
|
2016-03-08 10:24:26 +00:00
|
|
|
{
|
2019-04-04 11:53:29 +00:00
|
|
|
$this->result = eval("return ".$this->expression.";");
|
|
|
|
return $this;
|
|
|
|
}
|
2016-03-08 10:24:26 +00:00
|
|
|
|
2019-04-04 11:53:29 +00:00
|
|
|
public function getResult()
|
2016-03-08 10:24:26 +00:00
|
|
|
{
|
2019-04-04 11:53:29 +00:00
|
|
|
return $this->result;
|
|
|
|
}
|
2016-03-08 10:24:26 +00:00
|
|
|
}
|
|
|
|
|
2019-04-04 11:53:29 +00:00
|
|
|
class SupportgroupsNegativeFinder
|
2016-03-08 10:24:26 +00:00
|
|
|
{
|
2019-04-04 11:53:29 +00:00
|
|
|
protected $expressionObj;
|
2016-03-08 10:24:26 +00:00
|
|
|
|
2019-04-04 11:53:29 +00:00
|
|
|
public function __construct(SupportgroupsExpression $expressionObj)
|
2016-03-08 10:24:26 +00:00
|
|
|
{
|
2019-04-04 11:53:29 +00:00
|
|
|
$this->expressionObj = $expressionObj;
|
|
|
|
}
|
2016-03-08 10:24:26 +00:00
|
|
|
|
|
|
|
|
2019-04-04 11:53:29 +00:00
|
|
|
public function isItNegative()
|
2016-03-08 10:24:26 +00:00
|
|
|
{
|
2019-04-04 11:53:29 +00:00
|
|
|
$result = $this->expressionObj->evaluate()->getResult();
|
|
|
|
|
|
|
|
if($this->hasMinusSign($result))
|
2016-03-08 10:24:26 +00:00
|
|
|
{
|
2019-04-04 11:53:29 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-03-08 10:24:26 +00:00
|
|
|
else
|
|
|
|
{
|
2019-04-04 11:53:29 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2016-03-08 10:24:26 +00:00
|
|
|
|
2019-04-04 11:53:29 +00:00
|
|
|
protected function hasMinusSign($value)
|
2016-03-08 10:24:26 +00:00
|
|
|
{
|
2019-04-04 11:53:29 +00:00
|
|
|
return (substr(strval($value), 0, 1) == "-");
|
|
|
|
}
|
2016-03-08 10:24:26 +00:00
|
|
|
}
|