HasSpecifications::specifications()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace Pbmedia\Specifications;
4
5
use Pbmedia\Specifications\Interfaces\Specifications as SpecificationsInterface;
6
7
trait HasSpecifications
8
{
9
    /**
10
     * Instance of Specifications.
11
     *
12
     * @var \Pbmedia\Specifications\Interfaces\Specifications
13
     */
14
    protected $specifications;
15
16
    /**
17
     * Creates a new Specifications object if non exists
18
     * and returns it.
19
     *
20
     * @return \Pbmedia\Specifications\Specifications
21
     */
22
    public function specifications(): SpecificationsInterface
23
    {
24
        if (!$this->specifications) {
25
            $this->specifications = new Specifications;
26
        }
27
28
        return $this->specifications;
29
    }
30
}
31