Completed
Push — Lonja/albertc ( 7a2bf6 )
by Albert
20:41 queued 16:20
created

PriceStrategy   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 24
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A instance() 0 4 1
A price() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kata\Application\CityPriceStrategy;
6
7
use Kata\Domain\Common\ValueObject\Price;
8
use Kata\Domain\Product\Model\Product;
9
10
class PriceStrategy implements Strategy
11
{
12
    /** @var Product  */
13
    private $product;
14
15
    /** @var Price  */
16
    private $price;
17
18
    public function __construct(Product $product, Price $price)
19
    {
20
        $this->product = $product;
21
        $this->price = $price;
22
    }
23
24
    public static function instance(Product $product, Price $price): PriceStrategy
25
    {
26
        return new self($product, $price);
27
    }
28
29
    public function price(): float
30
    {
31
        return $this->price->amount();
32
    }
33
}
34