Code Duplication    Length = 24-26 lines in 2 locations

src/Connectors/Facebook.php 1 location

@@ 116-141 (lines=26) @@
113
        return $response;
114
    }
115
116
    public function getProfile()
117
    {
118
        if (is_null($this->profile)) {
119
            $path = '/me';
120
            $result = $this->request($path);
121
            $json_result = json_decode($result, true);
122
123
            $mapping = [
124
                'id' => 'id',
125
                'email' => 'email',
126
                'name' => 'name',
127
                'first_name' => 'first_name',
128
                'middle_name' => 'middle_name',
129
                'last_name' => 'last_name',
130
                'username' => 'username',
131
                // 'username' => 'email', // Facebook Graph API 2.0 doesn't have username
132
                'link' => 'link'
133
            ];
134
135
            $this->profile = Profile::create($mapping, $json_result);
136
            $this->profile->provider = static::$provider;
137
            $this->profile->raw_response = $result;
138
        }
139
140
        return $this->profile;
141
    }
142
143
    public function getPermissions()
144
    {

src/Connectors/FacebookPage.php 1 location

@@ 69-92 (lines=24) @@
66
        return $response;
67
    }
68
69
    public function getPage()
70
    {
71
        if (is_null($this->page)) {
72
            $path = '/'.$this->id.'?fields=id,name,picture,access_token,can_post,likes,fan_count,link,username';
73
            $result = $this->request($path);
74
            $json_result = json_decode($result, true);
75
76
            $mapping = [
77
                'id' => 'id',
78
                'name' => 'name',
79
                'link' => 'link',
80
                'can_post' => 'can_post',
81
                'access_token' => 'access_token',
82
                'likes' => 'likes',
83
                'fan_count' => 'fan_count'
84
            ];
85
86
            $this->page = Page::create($mapping, $json_result);
87
            $this->page->provider = static::$provider;
88
            $this->page->raw_response = $result;
89
        }
90
91
        return $this->page;
92
    }
93
94
95
    /**