ContactCriteria   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 118
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 6
dl 0
loc 118
ccs 0
cts 66
cp 0
rs 10
c 0
b 0
f 0

6 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
A batch() 0 11 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\Contact;
12
use Psr\Http\Message\ResponseInterface;
13
14
/**
15
 * @author Flipbox Factory <[email protected]>
16
 * @since 2.0.0
17
 */
18
class ContactCriteria 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 Contact::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
     */
49
    public function create(array $criteria = [], array $config = []): ResponseInterface
50
    {
51
        $this->populate($criteria);
52
53
        return Contact::create(
54
            $this->getPayload(),
55
            $this->getConnection(),
56
            $this->getLogger(),
57
            $config
58
        );
59
    }
60
61
    /**
62
     * @param array $criteria
63
     * @param array $config
64
     * @return ResponseInterface
65
     * @throws \Exception
66
     */
67
    public function update(array $criteria = [], array $config = []): ResponseInterface
68
    {
69
        $this->populate($criteria);
70
71
        return Contact::update(
72
            $this->getPayload(),
73
            $this->getId(),
74
            $this->getConnection(),
75
            $this->getCache(),
76
            $this->getLogger(),
77
            $config
78
        );
79
    }
80
81
    /**
82
     * @param array $criteria
83
     * @param array $config
84
     * @return ResponseInterface
85
     */
86
    public function upsert(array $criteria = [], array $config = []): ResponseInterface
87
    {
88
        $this->populate($criteria);
89
90
        return Contact::upsert(
91
            $this->getPayload(),
92
            $this->findId(),
93
            $this->getConnection(),
94
            $this->getCache(),
95
            $this->getLogger(),
96
            $config
97
        );
98
    }
99
100
    /**
101
     * @param array $criteria
102
     * @param array $config
103
     * @return ResponseInterface
104
     * @throws \Exception
105
     */
106
    public function delete(array $criteria = [], array $config = []): ResponseInterface
107
    {
108
        $this->populate($criteria);
109
110
        return Contact::delete(
111
            $this->getId(),
112
            $this->getConnection(),
113
            $this->getCache(),
114
            $this->getLogger(),
115
            $config
116
        );
117
    }
118
119
    /**
120
     * @param array $criteria
121
     * @param array $config
122
     * @return ResponseInterface
123
     */
124
    public function batch(array $criteria = [], array $config = []): ResponseInterface
125
    {
126
        $this->populate($criteria);
127
128
        return Contact::batch(
129
            $this->getPayload(),
130
            $this->getConnection(),
131
            $this->getLogger(),
132
            $config
133
        );
134
    }
135
}
136