IdAttributeTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 37
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 7 2
A findId() 0 4 1
A setId() 0 5 1
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipbox/salesforce/blob/master/LICENSE.md
6
 * @link       https://github.com/flipbox/salesforce
7
 */
8
9
namespace Flipbox\Salesforce\Criteria;
10
11
/**
12
 * @author Flipbox Factory <[email protected]>
13
 * @since 3.3.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