PickupLocation::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 6
rs 10
c 1
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\AgencyCar;
10
11
use Ticaje\BookingApi\Application\Repository\AssignedRepositoryInterface;
0 ignored issues
show
Bug introduced by
The type Ticaje\BookingApi\Applic...gnedRepositoryInterface 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\Repository\DisabledRepositoryInterface;
0 ignored issues
show
Bug introduced by
The type Ticaje\BookingApi\Applic...bledRepositoryInterface 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...
13
use Ticaje\BookingApi\Application\Signatures\Provider\ServiceProviderSignature;
14
use Ticaje\Contract\Persistence\Repository\RepositoryInterface as BaseRepositoryInterface;
15
use Ticaje\Hexagonal\Application\Signatures\UseCase\UseCaseCommandInterface;
16
17
/**
18
 * Class PickupLocation
19
 * @package Ticaje\BookingApi\Application\Service\Provider\AgencyCar
20
 */
21
class PickupLocation implements ServiceProviderSignature
22
{
23
    /** @var AssignedRepositoryInterface $assignedRepository */
24
    private $assignedRepository;
25
26
    /** @var DisabledRepositoryInterface $disabledRepository */
27
    private $disabledRepository;
28
29
    /**
30
     * PickupLocation constructor.
31
     *
32
     * @param BaseRepositoryInterface $assignedRepository
33
     * @param BaseRepositoryInterface $disabledRepository
34
     */
35
    public function __construct(
36
        BaseRepositoryInterface $assignedRepository,
37
        BaseRepositoryInterface $disabledRepository
38
    ) {
39
        $this->assignedRepository = $assignedRepository;
0 ignored issues
show
Documentation Bug introduced by
It seems like $assignedRepository of type Ticaje\Contract\Persiste...ory\RepositoryInterface is incompatible with the declared type Ticaje\BookingApi\Applic...gnedRepositoryInterface of property $assignedRepository.

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...
40
        $this->disabledRepository = $disabledRepository;
0 ignored issues
show
Documentation Bug introduced by
It seems like $disabledRepository of type Ticaje\Contract\Persiste...ory\RepositoryInterface is incompatible with the declared type Ticaje\BookingApi\Applic...bledRepositoryInterface of property $disabledRepository.

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...
41
    }
42
43
    /**
44
     * @inheritDoc
45
     */
46
    public function execute(UseCaseCommandInterface $command)
47
    {
48
        $result = [];
49
        $assigned = $this->assignedRepository->getAssignedForCar($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

49
        $assigned = $this->assignedRepository->getAssignedForCar($command->/** @scrutinizer ignore-call */ getProductId());
Loading history...
50
        foreach ($assigned as $item) {
51
            $disabled = $this->disabledRepository->getDisabledRulesForLocationAndCar($item->getId(), $command->getFromDate(), $command->getToDate());
0 ignored issues
show
Bug introduced by
The method getToDate() 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

51
            $disabled = $this->disabledRepository->getDisabledRulesForLocationAndCar($item->getId(), $command->getFromDate(), $command->/** @scrutinizer ignore-call */ getToDate());
Loading history...
Bug introduced by
The method getFromDate() 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

51
            $disabled = $this->disabledRepository->getDisabledRulesForLocationAndCar($item->getId(), $command->/** @scrutinizer ignore-call */ getFromDate(), $command->getToDate());
Loading history...
52
            if (count($disabled) > 0) {
53
                continue;
54
            }
55
            $result[$item->getId()] = $item;
56
        }
57
58
        return $result;
59
    }
60
}
61