Completed
Push — master ( 1e5bea...c96873 )
by Thijs
14s queued 10s
created

findCustomAccountField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
dl 10
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace TestMonitor\ActiveCampaign\Actions;
4
5
use TestMonitor\ActiveCampaign\Resources\AccountCustomField;
6
7 View Code Duplication
trait ManagesAccountCustomFields
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    use ImplementsActions;
10
11
    /**
12
     * Get all custom fields.
13
     *
14
     * @return array
15
     */
16
    public function customAccountFields()
17
    {
18
        return $this->transformCollection(
19
            $this->get('accountCustomFieldMeta'),
20
            AccountCustomField::class,
21
            'accountCustomFieldMeta'
22
        );
23
    }
24
25
    /**
26
     * Find custom field by name.
27
     *
28
     * @param string $name
29
     *
30
     * @return AccountCustomField|null
31
     */
32
    public function findCustomAccountField($name)
33
    {
34
        $customFields = $this->transformCollection(
35
            $this->get('accountCustomFieldMeta', ['query' => ['filters[fieldLabel]' => $name]]),
36
            AccountCustomField::class,
37
            'accountCustomFieldMeta'
38
        );
39
40
        return array_shift($customFields);
41
    }
42
}
43