IdAttributeTrait::getId()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipbox/hubspot/blob/master/LICENSE.md
6
 * @link       https://github.com/flipbox/hubspot
7
 */
8
9
namespace Flipbox\HubSpot\Criteria;
10
11
/**
12
 * @author Flipbox Factory <[email protected]>
13
 * @since 2.0.0
14
 */
15
trait IdAttributeTrait
16
{
17
    /**
18
     * @var string|null
19
     */
20
    protected $id;
21
22
    /**
23
     * @return string
24
     * @throws \Exception
25
     */
26
    public function getId(): string
27
    {
28
        if (null === ($id = $this->findId())) {
29
            throw new \Exception("Invalid Object Id");
30
        }
31
        return $id;
32
    }
33
34
    /**
35
     * @return string|null
36
     */
37
    public function findId()
38
    {
39
        return $this->id;
40
    }
41
42
    /**
43
     * @param string|null $id
44
     * @return $this
45
     */
46
    public function setId(string $id = null)
47
    {
48
        $this->id = $id;
49
        return $this;
50
    }
51
}
52