Test Failed
Push — main ( f1b82a...d2d042 )
by Bingo
06:24
created

JsonTaskQueryVariableValueConverter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 12
c 1
b 0
f 0
dl 0
loc 19
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toJsonObject() 0 7 1
A toObject() 0 8 1
1
<?php
2
3
namespace Jabe\Engine\Impl\Json;
4
5
use Jabe\Engine\Impl\{
6
    QueryOperator,
7
    TaskQueryVariableValue
8
};
9
use Jabe\Engine\Impl\Util\JsonUtil;
10
11
class JsonTaskQueryVariableValueConverter extends JsonObjectConverter
12
{
13
    public function toJsonObject(/*TaskQueryVariableValue*/$object, bool $isOrQueryActive = false): ?\stdClass
14
    {
15
        $jsonObject = JsonUtil::createObject();
16
        JsonUtil::addField($jsonObject, "name", $variable->getName());
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $variable seems to be never defined.
Loading history...
17
        JsonUtil::addFieldRawValue($jsonObject, "value", $variable->getValue());
18
        JsonUtil::addField($jsonObject, "operator", $variable->getOperator());
19
        return $jsonObject;
20
    }
21
22
    public function toObject(\stdClass $jsonString, bool $isOrQuery = false)
23
    {
24
        $name = JsonUtil::getString($json, "name");
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $json seems to be never defined.
Loading history...
25
        $value = JsonUtil::getRawObject($json, "value");
0 ignored issues
show
Bug introduced by
The method getRawObject() does not exist on Jabe\Engine\Impl\Util\JsonUtil. Did you maybe mean getObject()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
        /** @scrutinizer ignore-call */ 
26
        $value = JsonUtil::getRawObject($json, "value");

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
26
        $operator = constant("QueryOperator::", JsonUtil::getString($json, "operator"));
0 ignored issues
show
Unused Code introduced by
The call to constant() has too many arguments starting with Jabe\Engine\Impl\Util\Js...ring($json, 'operator'). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        $operator = /** @scrutinizer ignore-call */ constant("QueryOperator::", JsonUtil::getString($json, "operator"));

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
27
        $isTaskVariable = JsonUtil::getBoolean($json, "taskVariable");
28
        $isProcessVariable = JsonUtil::getBoolean($json, "processVariable");
29
        return new TaskQueryVariableValue($name, $value, $operator, $isTaskVariable, $isProcessVariable);
30
    }
31
}
32