AbstractSubscriptionStrategy   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 48
ccs 10
cts 10
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getProductStrategy() 0 3 1
A __construct() 0 4 1
A createSubscriptionInstance() 0 3 1
A createCurrentDate() 0 3 1
1
<?php
2
3
namespace Terox\SubscriptionBundle\Strategy;
4
5
use Terox\SubscriptionBundle\Model\SubscriptionInterface;
6
7
abstract class AbstractSubscriptionStrategy implements SubscriptionStrategyInterface
8
{
9
    /**
10
     * @var string
11
     */
12
    private $subscriptionClass;
13
14
    /**
15
     * @var AbstractProductStrategy
16
     */
17
    private $productStrategy;
18
19
    /**
20
     * Constructor.
21
     *
22
     * @param string                  $subscriptionClass
23
     * @param AbstractProductStrategy $productStrategy
24
     */
25 21
    public function __construct($subscriptionClass, AbstractProductStrategy $productStrategy)
26
    {
27 21
        $this->subscriptionClass = $subscriptionClass;
28 21
        $this->productStrategy   = $productStrategy;
29 21
    }
30
31
    /**
32
     * @return SubscriptionInterface
33
     */
34 8
    public function createSubscriptionInstance()
35
    {
36 8
        return new $this->subscriptionClass();
37
    }
38
39
    /**
40
     * @return AbstractProductStrategy
41
     */
42 7
    public function getProductStrategy()
43
    {
44 7
        return $this->productStrategy;
45
    }
46
47
    /**
48
     * Create current date.
49
     *
50
     * @return \DateTimeImmutable
51
     */
52 5
    protected function createCurrentDate()
53
    {
54 5
        return new \DateTimeImmutable();
55
    }
56
}
57