Test Setup Failed
Push — master ( f402dd...7296e4 )
by Hector Luis
05:56
created

Package::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
/**
4
 * Application Service Class
5
 * @package Ticaje_BookingApi
6
 * @author  Hector Luis Barrientos <[email protected]>
7
 */
8
9
namespace Ticaje\BookingApi\Application\Service\Provider\Package;
10
11
use Ticaje\BookingApi\Application\Repository\PackageRepositoryInterface;
0 ignored issues
show
Bug introduced by
The type Ticaje\BookingApi\Applic...kageRepositoryInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Ticaje\BookingApi\Application\Signatures\Provider\Package\PackageProviderSignature;
13
use Ticaje\Contract\Persistence\Entity\EntityInterface;
14
use Ticaje\Contract\Persistence\Repository\RepositoryInterface as BaseRepositoryInterface;
15
use Ticaje\Hexagonal\Application\Signatures\UseCase\UseCaseCommandInterface;
16
17
/**
18
 * Class Package
19
 * @package Ticaje\BookingApi\Application\Service\Provider
20
 */
21
class Package implements PackageProviderSignature
22
{
23
    /** @var PackageRepositoryInterface $circuitRepository */
24
    private $circuitRepository;
25
26
    /** @var EntityInterface $circuit */
27
    private $circuit;
28
29
    public function __construct(
30
        BaseRepositoryInterface $circuitRepository
31
    ) {
32
        $this->circuitRepository = $circuitRepository;
0 ignored issues
show
Documentation Bug introduced by
It seems like $circuitRepository of type Ticaje\Contract\Persiste...ory\RepositoryInterface is incompatible with the declared type Ticaje\BookingApi\Applic...kageRepositoryInterface of property $circuitRepository.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
33
    }
34
35
    /**
36
     * @inheritDoc
37
     */
38
    public function instance(UseCaseCommandInterface $command): PackageProviderSignature
39
    {
40
        $productId = $command->getProductId();
0 ignored issues
show
Bug introduced by
The method getProductId() does not exist on Ticaje\Hexagonal\Applica...UseCaseCommandInterface. It seems like you code against a sub-type of Ticaje\Hexagonal\Applica...UseCaseCommandInterface such as Ticaje\BookingApi\Applic...and\DisabledDaysCommand or Ticaje\BookingApi\Applic...etPickupLocationCommand or Ticaje\BookingApi\Applic...Command\GetPriceCommand or Ticaje\BookingApi\Applic...mmand\GetPackageCommand or Ticaje\BookingApi\Applic...\GetAvailabilityCommand. ( Ignorable by Annotation )

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

40
        /** @scrutinizer ignore-call */ 
41
        $productId = $command->getProductId();
Loading history...
41
        $storeId = $command->getStoreId();
0 ignored issues
show
Bug introduced by
The method getStoreId() does not exist on Ticaje\Hexagonal\Applica...UseCaseCommandInterface. It seems like you code against a sub-type of Ticaje\Hexagonal\Applica...UseCaseCommandInterface such as Ticaje\BookingApi\Applic...and\DisabledDaysCommand or Ticaje\BookingApi\Applic...etPickupLocationCommand or Ticaje\BookingApi\Applic...Command\GetPriceCommand or Ticaje\BookingApi\Applic...mmand\GetPackageCommand or Ticaje\BookingApi\Applic...\GetAvailabilityCommand. ( Ignorable by Annotation )

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

41
        /** @scrutinizer ignore-call */ 
42
        $storeId = $command->getStoreId();
Loading history...
42
        $this->circuit = $this->circuitRepository->getByProductAndStore($productId, $storeId);
43
44
        return $this;
45
    }
46
47
    /**
48
     * @inheritDoc
49
     */
50
    public function getAvailability(int $from, int $to): bool
51
    {
52
        // @todo implementation
53
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return boolean. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
54
55
    /**
56
     * @inheritDoc
57
     */
58
    public function getDepartureDays(): array
59
    {
60
        $result = unserialize($this->circuit->getDepartureDays());
0 ignored issues
show
Bug introduced by
The method getDepartureDays() does not exist on Ticaje\Contract\Persistence\Entity\EntityInterface. ( Ignorable by Annotation )

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

60
        $result = unserialize($this->circuit->/** @scrutinizer ignore-call */ getDepartureDays());

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...
61
62
        return array_map(function ($value) {
63
            return $value - 1;
64
        }, $result);
65
    }
66
67
    /**
68
     * @inheritDoc
69
     */
70
    public function getNumberOfNights(): int
71
    {
72
        return (int)$this->circuit->getNumberOfNights();
0 ignored issues
show
Bug introduced by
The method getNumberOfNights() does not exist on Ticaje\Contract\Persistence\Entity\EntityInterface. ( Ignorable by Annotation )

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

72
        return (int)$this->circuit->/** @scrutinizer ignore-call */ getNumberOfNights();

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...
73
    }
74
75
    /**
76
     * @inheritDoc
77
     */
78
    public function getDateTo(): string
79
    {
80
        return $this->circuit->getDateTo();
0 ignored issues
show
Bug introduced by
The method getDateTo() does not exist on Ticaje\Contract\Persistence\Entity\EntityInterface. ( Ignorable by Annotation )

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

80
        return $this->circuit->/** @scrutinizer ignore-call */ getDateTo();

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...
81
    }
82
}
83