PriceAggregate   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getBasePrice() 0 7 2
A getPrice() 0 3 1
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\Service\Provider\BasePriceProvider;
12
use Ticaje\BookingApi\Application\Signatures\Provider\PriceProviderSignature;
13
use Ticaje\Contract\Patterns\Interfaces\Dto\DtoInterface;
14
use Ticaje\Hexagonal\Application\Signatures\UseCase\UseCaseCommandInterface;
15
16
/**
17
 * Class Price
18
 * @package Ticaje\BookingApi\Application\Service\Provider
19
 */
20
class PriceAggregate extends BasePriceProvider implements PriceProviderSignature
21
{
22
    /**
23
     * @inheritDoc
24
     */
25
    protected function getBasePrice(UseCaseCommandInterface $command): float
26
    {
27
        /** @var DtoInterface $product */
28
        $product = $command->getProduct();
0 ignored issues
show
Bug introduced by
The method getProduct() 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

28
        /** @scrutinizer ignore-call */ 
29
        $product = $command->getProduct();
Loading history...
29
        $result = $product ? $product->getPrice() : 0;
0 ignored issues
show
introduced by
$product is of type Ticaje\Contract\Patterns...rfaces\Dto\DtoInterface, thus it always evaluated to true.
Loading history...
30
31
        return (float)$result;
32
    }
33
34
    /**
35
     * @inheritDoc
36
     */
37
    public function getPrice(UseCaseCommandInterface $command): float
38
    {
39
        return (float)$this->instance->getPrice();
0 ignored issues
show
Bug introduced by
The method getPrice() 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

39
        return (float)$this->instance->/** @scrutinizer ignore-call */ getPrice();

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...
40
    }
41
}
42