Completed
Push — master ( f8bee3...25dc98 )
by Paweł
12s
created

MediaDetails::map()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 22
nc 1
nop 0
1
<?php
2
/**
3
 * Created for IG Client.
4
 * User: jakim <[email protected]>
5
 * Date: 23.03.2018
6
 */
7
8
namespace Jakim\Mapper;
9
10
11
use Jakim\Base\Mapper;
12
use Jakim\Contract\MapperInterface;
13
use Jakim\Model\Account;
14
use Jakim\Model\Post;
15
16
class MediaDetails extends Mapper implements MapperInterface
17
{
18
    protected function map(): array
19
    {
20
        return [
21
            Post::class => [
22
                'envelope' => 'graphql.shortcode_media',
23
                'item' => [
24
                    'id' => 'id',
25
                    'shortcode' => 'shortcode',
26
                    'url' => 'display_url',
27
                    'caption' => 'edge_media_to_caption.edges.0.node.text',
28
                    'likes' => 'edge_media_preview_like.count',
29
                    'comments' => 'edge_media_to_comment.count',
30
                    'takenAt' => 'taken_at_timestamp',
31
                    'isVideo' => 'is_video',
32
                ],
33
                'relations' => [
34
                    'account' => Account::class,
35
                ],
36
            ],
37
            Account::class => [
38
                'envelope' => 'owner', //related to parent map
39
                'item' => [
40
                    'id' => 'id',
41
                    'username' => 'username',
42
                    'profilePicUrl' => 'profile_pic_url',
43
                    'fullName' => 'full_name',
44
                    'isPrivate' => 'is_private',
45
                ],
46
            ],
47
        ];
48
    }
49
}