ObjectAttributeTrait::findObject()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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 ObjectAttributeTrait
16
{
17
    /**
18
     * @var string|null
19
     */
20
    protected $object;
21
22
    /**
23
     * @return string
24
     * @throws \Exception
25
     */
26
    public function getObject(): string
27
    {
28
        if (null === ($object = $this->findObject())) {
29
            throw new \Exception("Invalid Object");
30
        }
31
        return $object;
32
    }
33
34
    /**
35
     * @return string|null
36
     */
37
    public function findObject()
38
    {
39
        return $this->object;
40
    }
41
42
    /**
43
     * @param string|null $object
44
     * @return $this
45
     */
46
    public function setObject(string $object = null)
47
    {
48
        $this->object = $object;
49
        return $this;
50
    }
51
}
52