Passed
Push — master ( 7aad7b...826680 )
by Paweł
03:40
created

EdgeAccounts::config()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 28
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 23
c 1
b 0
f 1
dl 0
loc 28
rs 9.552
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Created for IG Client.
4
 * User: jakim <[email protected]>
5
 * Date: 24/12/2019
6
 */
7
8
namespace Jakim\Mapper;
9
10
11
use Jakim\Base\Mapper;
12
use Jakim\Model\Account;
13
use Jakim\Model\AccountsCollection;
14
use Jakim\Model\PageInfo;
15
16
class EdgeAccounts extends Mapper
17
{
18
    const FOLLOWERS_ENVELOPE = 'data.user.edge_followed_by';
19
20
    protected $envelope = self::FOLLOWERS_ENVELOPE;
21
22
    public function __construct(string $envelope = self::FOLLOWERS_ENVELOPE)
23
    {
24
        $this->setEnvelope($envelope);
25
    }
26
27
    public function setEnvelope($key)
28
    {
29
        $this->envelope = $key;
30
    }
31
32
    /**
33
     * @inheritDoc
34
     */
35
    public function config(): array
36
    {
37
        return [
38
            'class' => AccountsCollection::class,
39
            'envelope' => $this->envelope,
40
            'properties' => [
41
                'count' => 'count',
42
            ],
43
            'relations' => [
44
                'pageInfo' => [
45
                    'class' => PageInfo::class,
46
                    'envelope' => 'page_info',
47
                    'properties' => [
48
                        'hasNextPage' => 'has_next_page',
49
                        'endCursor' => 'end_cursor',
50
                    ],
51
                ],
52
                'accounts' => [
53
                    'multiple' => true,
54
                    'class' => Account::class,
55
                    'envelope' => 'edges',
56
                    'properties' => [
57
                        'id' => 'node.id',
58
                        'username' => 'node.username',
59
                        'fullName' => 'node.full_name',
60
                        'profilePicUrl' => 'node.profile_pic_url',
61
                        'isPrivate' => 'node.is_private',
62
                        'isVerified' => 'node.is_verified',
63
                    ],
64
                ],
65
            ],
66
        ];
67
    }
68
}