AssociateObject   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 24
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 17 3
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\craft\hubspot\actions\objects;
10
11
use flipbox\craft\hubspot\fields\ObjectsFieldInterface;
12
use flipbox\craft\integration\actions\objects\AssociateObject as AssociateIntegration;
13
use flipbox\craft\integration\records\IntegrationAssociation;
14
use Psr\Http\Message\ResponseInterface;
15
16
/**
17
 * @author Flipbox Factory <[email protected]>
18
 * @since 1.0.0
19
 */
20
class AssociateObject extends AssociateIntegration
21
{
22
    /**
23
     * @inheritdoc
24
     * @param IntegrationAssociation $record
25
     */
26
    protected function validate(
27
        IntegrationAssociation $record
28
    ): bool {
29
30
        $field = $record->getField();
31
32
        if (!$field instanceof ObjectsFieldInterface) {
33
            return false;
34
        }
35
36
        /** @var ResponseInterface $response */
37
        $response = $field->readFromHubSpot(
38
            $record->objectId
39
        );
40
41
        return $response->getStatusCode() >= 200 && $response->getStatusCode() <= 299;
42
    }
43
}
44