class Class1
{
public function doSomethingWithClass2Object(Class2 $obj2)
{
}
}
class Class2
{
public function doSomethingWithClass1Object(Class1 $obj1)
{
}
}
class ClassFacade
{
private Class1 $class1;
private Class2 $class2;
public function __construct()
{
$this->class1 = app(Class1::class);
$this->class2 = app(Class2::class);
}
public function doSomething()
{
$this->class1->doSomethingWithClass2Object($this->class2);
$this->class2->doSomethingWithClass1Object($this->class1);
}
}
' . ($product->stars ?? 0) . '
' . (isset($product->stars) ? $product->stars : 0) . '
class RuleHelper
{
/**
* Checks rule for value
* @param mixed $value value to check
* @param string $rule rule for checking
* @param array $args arguments for rule
* @return bool
*/
public static function check($value, string $rule, array $args): bool
{
switch($rule) {
case '=':
if((string)$value === (string)$args[0]) {
return true;
}
break;
case '!=':
if((string)$value !== (string)$args[0]) {
return true;
}
break;
case '>':
if($value > $args[0]) {
return true;
}
break;
case '>=':
if($value >= $args[0]) {
return true;
}
break;
case '<':
if($value < $args[0]) {
return true;
}
break;
case '<=':
if($value <= $args[0]) {
return true;
}
break;
case 'between':
if($value >= $args[0] && $value <= $args[1]) {
return true;
}
break;
case 'in':
if(in_array($value, $args[0])) {
return true;
}
break;
case 'not in':
if(!in_array($value, $args[0])) {
return true;
}
break;
case 'between strict':
if($value > $args[0] && $value < $args[1]) {
return true;
}
break;
}
return false;
}
}
RuleHelper::check($operand1, $row['compareSign'], $operand2);