FoxyFactory::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 2
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Dynamic\Foxy\Orders\Factory;
4
5
use Dynamic\Foxy\Parser\Foxy\Transaction;
6
use SilverStripe\Core\Config\Configurable;
7
use SilverStripe\Core\Injector\Injectable;
8
9
/**
10
 * Class FoxyFactory
11
 * @package Dynamic\Foxy\Orders\Factory
12
 */
13
class FoxyFactory
14
{
15
    use Configurable;
16
    use Injectable;
17
18
    /**
19
     * @var Transaction
20
     */
21
    private $transaction;
22
23
    /**
24
     * OrderDetailFactory constructor.
25
     * @param Transaction|null $transaction
26
     */
27
    public function __construct(Transaction $transaction = null)
28
    {
29
        if ($transaction instanceof Transaction && $transaction !== null) {
30
            $this->setTransaction($transaction);
31
        }
32
    }
33
34
    /**
35
     * @param Transaction $transaction
36
     * @return $this
37
     */
38
    public function setTransaction(Transaction $transaction)
39
    {
40
        $this->transaction = $transaction;
41
42
        return $this;
43
    }
44
45
    /**
46
     * @return Transaction
47
     */
48
    protected function getTransaction()
49
    {
50
        return $this->transaction;
51
    }
52
}
53