Completed
Push — develop ( 1d947e...a9d8b7 )
by Nate
05:38
created

CompanyCriteria   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 84
ccs 0
cts 36
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A read() 0 9 1
A create() 0 9 1
A update() 0 9 1
A delete() 0 9 1
A fetch() 0 4 1
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/hubspot/license
6
 * @link       https://www.flipboxfactory.com/software/hubspot/
7
 */
8
9
namespace flipbox\hubspot\criteria;
10
11
use flipbox\hubspot\HubSpot;
12
use flipbox\hubspot\services\resources\Companies;
13
use flipbox\hubspot\transformers\collections\DynamicTransformerCollection;
14
use flipbox\hubspot\transformers\DynamicModelSuccess;
15
use flipbox\hubspot\transformers\collections\TransformerCollectionInterface;
16
17
/**
18
 * @author Flipbox Factory <[email protected]>
19
 * @since 1.0.0
20
 */
21
class CompanyCriteria extends ResourceCriteria
22
{
23
    /**
24
     * @inheritdoc
25
     */
26
    protected $transformer = [
27
        'class' => DynamicTransformerCollection::class,
28
        'handle' => Companies::HUBSPOT_RESOURCE,
29
        'transformers' => [
30
            TransformerCollectionInterface::SUCCESS_KEY => [
31
                'class' => DynamicModelSuccess::class,
32
                'resource' => Companies::HUBSPOT_RESOURCE
33
            ]
34
        ]
35
    ];
36
37
    /**
38
     * @param array $config
39
     * @param null $source
40
     * @return mixed
41
     */
42
    public function read(array $config = [], $source = null)
43
    {
44
        $this->prepare($config);
45
46
        return HubSpot::getInstance()
47
            ->getResources()
48
            ->getCompanies()
49
            ->readByCriteria($this, $source);
50
    }
51
52
    /**
53
     * @param array $config
54
     * @param null $source
55
     * @return mixed
56
     */
57
    public function create(array $config = [], $source = null)
58
    {
59
        $this->prepare($config);
60
61
        return HubSpot::getInstance()
62
            ->getResources()
63
            ->getCompanies()
64
            ->createByCriteria($this, $source);
65
    }
66
67
    /**
68
     * @param array $config
69
     * @param null $source
70
     * @return mixed
71
     */
72
    public function update(array $config = [], $source = null)
73
    {
74
        $this->prepare($config);
75
76
        return HubSpot::getInstance()
77
            ->getResources()
78
            ->getCompanies()
79
            ->updateByCriteria($this, $source);
80
    }
81
82
    /**
83
     * @param array $config
84
     * @param null $source
85
     * @return mixed
86
     */
87
    public function delete(array $config = [], $source = null)
88
    {
89
        $this->prepare($config);
90
91
        return HubSpot::getInstance()
92
            ->getResources()
93
            ->getCompanies()
94
            ->deleteByCriteria($this, $source);
95
    }
96
97
    /**
98
     * @inheritdoc
99
     */
100
    public function fetch(array $config = [])
101
    {
102
        return $this->read($config);
103
    }
104
}
105