Issues (2551)

src/Impl/Batch/DeploymentMappingJsonConverter.php (2 issues)

1
<?php
2
3
namespace Jabe\Impl\Batch;
4
5
use Jabe\Impl\Json\JsonObjectConverter;
6
use Jabe\Impl\Util\JsonUtil;
7
8
class DeploymentMappingJsonConverter extends JsonObjectConverter
9
{
10
    public static $INSTANCE;
11
12
    protected const COUNT = "count";
13
    protected const DEPLOYMENT_ID = "deploymentId";
14
15
    public function instance(): JsonObjectConverter
16
    {
17
        if (self::$INSTANCE === null) {
18
            self::$INSTANCE = new DeploymentMappingJsonConverter();
19
        }
20
        return self::$INSTANCE;
21
    }
22
23
    public function toJsonObject(/*BatchConfiguration*/$mapping, bool $isOrQueryActive = false): ?\stdClass
24
    {
25
        $json = JsonUtil::createObject();
26
        $json->addProperty(self::DEPLOYMENT_ID, $mapping->getDeploymentId());
0 ignored issues
show
The method addProperty() does not exist on stdClass. ( Ignorable by Annotation )

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

26
        $json->/** @scrutinizer ignore-call */ 
27
               addProperty(self::DEPLOYMENT_ID, $mapping->getDeploymentId());

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...
27
        $json->addProperty(self::COUNT, $mapping->getCount());
28
        return $json;
29
    }
30
31
    public function toObject(\stdClass $jsonObject, bool $isOrQuery = false)
32
    {
33
        $deploymentId = JsonUtil::isNull($jsonObject, self::DEPLOYMENT_ID) ? null : JsonUtil::getString($jsonObject, self::DEPLOYMENT_ID);
34
        $count = JsonUtil::getInt($jsonObject, self::COUNT);
35
        return new DeploymentMapping($deploymentId, $count);
0 ignored issues
show
It seems like $deploymentId can also be of type null; however, parameter $deploymentId of Jabe\Impl\Batch\DeploymentMapping::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

35
        return new DeploymentMapping(/** @scrutinizer ignore-type */ $deploymentId, $count);
Loading history...
36
    }
37
}
38