Completed
Push — master ( 9a4a9d...9fe695 )
by Paweł
02:34 queued 10s
created

MediaDetails::config()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 60
Code Lines 51

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 51
c 0
b 0
f 0
dl 0
loc 60
rs 9.069
cc 1
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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\Model\Account;
13
use Jakim\Model\Location;
14
use Jakim\Model\Post;
15
16
/**
17
 * Specific media mapper.
18
 *
19
 * @package Jakim\Mapper
20
 */
21
class MediaDetails extends Mapper
22
{
23
    public function config(): array
24
    {
25
        return [
26
            'class' => Post::class,
27
            'envelope' => 'graphql.shortcode_media',
28
            'properties' => [
29
                'id' => 'id',
30
                'shortcode' => 'shortcode',
31
                'url' => 'display_url',
32
                'caption' => 'edge_media_to_caption.edges.0.node.text',
33
                'likes' => 'edge_media_preview_like.count',
34
                'comments' => 'edge_media_preview_comment.count',
35
                'takenAt' => 'taken_at_timestamp',
36
                'isVideo' => 'is_video',
37
                'videoViews' => 'video_view_count',
38
                'videoUrl' => 'video_url',
39
                'typename' => '__typename',
40
                'accessibilityCaption' => 'accessibility_caption',
41
            ],
42
            'relations' => [
43
                'account' => [
44
                    'class' => Account::class,
45
                    'envelope' => 'owner', //related to parent map
46
                    'properties' => [
47
                        'id' => 'id',
48
                        'username' => 'username',
49
                        'profilePicUrl' => 'profile_pic_url',
50
                        'fullName' => 'full_name',
51
                        'isPrivate' => 'is_private',
52
                    ],
53
                ],
54
                'location' => [
55
                    'class' => Location::class,
56
                    'envelope' => 'location',
57
                    'properties' => [
58
                        'id' => 'id',
59
                        'hasPublicPage' => 'has_public_page',
60
                        'name' => 'name',
61
                        'slug' => 'slug',
62
                        'addressJson' => 'address_json',
63
                    ],
64
                ],
65
                'sponsor' => [
66
                    'class' => Account::class,
67
                    'envelope' => 'edge_media_to_sponsor_user.edges.0.node.sponsor', //related to parent map
68
                    'properties' => [
69
                        'id' => 'id',
70
                        'username' => 'username',
71
                    ],
72
                ],
73
                'tagged' => [
74
                    'multiple' => true,
75
                    'class' => Account::class,
76
                    'envelope' => 'edge_media_to_tagged_user.edges',
77
                    'properties' => [
78
                        'id' => 'node.user.id',
79
                        'username' => 'node.user.username',
80
                        'profilePicUrl' => 'node.user.profile_pic_url',
81
                        'fullName' => 'node.user.full_name',
82
                        'isVerified' => 'node.user.is_verified',
83
                    ],
84
                ],
85
            ],
86
        ];
87
    }
88
}