Completed
Push — master ( 3bdf28...70943d )
by Nate
02:14
created

CompanyCriteria   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 102
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 6
dl 0
loc 102
ccs 0
cts 56
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A read() 0 12 1
A create() 0 11 1
A update() 0 13 1
A upsert() 0 13 1
A delete() 0 12 1
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
use Flipbox\HubSpot\Resources\Company;
12
use Psr\Http\Message\ResponseInterface;
13
14
/**
15
 * @author Flipbox Factory <[email protected]>
16
 * @since 2.0.0
17
 */
18
class CompanyCriteria extends AbstractCriteria
19
{
20
    use ConnectionTrait,
21
        CacheTrait,
22
        IdAttributeTrait,
23
        PayloadAttributeTrait;
24
25
    /**
26
     * @param array $criteria
27
     * @param array $config
28
     * @return ResponseInterface
29
     * @throws \Exception
30
     */
31
    public function read(array $criteria = [], array $config = []): ResponseInterface
32
    {
33
        $this->populate($criteria);
34
35
        return Company::read(
36
            $this->getId(),
37
            $this->getConnection(),
38
            $this->getCache(),
39
            $this->getLogger(),
40
            $config
41
        );
42
    }
43
44
    /**
45
     * @param array $criteria
46
     * @param array $config
47
     * @return ResponseInterface
48
     * @throws \Exception
49
     */
50
    public function create(array $criteria = [], array $config = []): ResponseInterface
51
    {
52
        $this->populate($criteria);
53
54
        return Company::create(
55
            $this->getPayload(),
56
            $this->getConnection(),
57
            $this->getLogger(),
58
            $config
59
        );
60
    }
61
62
    /**
63
     * @param array $criteria
64
     * @param array $config
65
     * @return ResponseInterface
66
     * @throws \Exception
67
     */
68
    public function update(array $criteria = [], array $config = []): ResponseInterface
69
    {
70
        $this->populate($criteria);
71
72
        return Company::update(
73
            $this->getPayload(),
74
            $this->getId(),
75
            $this->getConnection(),
76
            $this->getCache(),
77
            $this->getLogger(),
78
            $config
79
        );
80
    }
81
82
    /**
83
     * @param array $criteria
84
     * @param array $config
85
     * @return ResponseInterface
86
     */
87
    public function upsert(array $criteria = [], array $config = []): ResponseInterface
88
    {
89
        $this->populate($criteria);
90
91
        return Company::upsert(
92
            $this->getPayload(),
93
            $this->findId(),
94
            $this->getConnection(),
95
            $this->getCache(),
96
            $this->getLogger(),
97
            $config
98
        );
99
    }
100
101
    /**
102
     * @param array $criteria
103
     * @param array $config
104
     * @return ResponseInterface
105
     * @throws \Exception
106
     */
107
    public function delete(array $criteria = [], array $config = []): ResponseInterface
108
    {
109
        $this->populate($criteria);
110
111
        return Company::delete(
112
            $this->getId(),
113
            $this->getConnection(),
114
            $this->getCache(),
115
            $this->getLogger(),
116
            $config
117
        );
118
    }
119
}
120