ResourceGeneric::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * MercadoLibre Provider for OAuth 2.0 Client
4
 *
5
 * Licensed under The MIT License
6
 * For full copyright and license information, please see the LICENSE file
7
 * Redistributions of files must retain the above copyright notice.
8
 *
9
 * @copyright 2018 Lucas Banegas <[email protected]>
10
 * @license https://opensource.org/licenses/MIT MIT License
11
 * @author Lucas Banegas <[email protected]>
12
 * @link https://github.com/docta/oauth2-mercadolibre Repository
13
 * @link https://docta.github.io/oauth2-mercadolibre Documentation
14
 */
15
namespace Docta\MercadoLibre\OAuth2\Client;
16
17
use League\OAuth2\Client\Tool\ArrayAccessorTrait;
18
19
/**
20
 * Represents a generic resource.
21
 */
22
class ResourceGeneric
23
{
24
    use ArrayAccessorTrait;
25
26
    /**
27
     * @var array
28
     */
29
    protected $response;
30
31
    /**
32
     * Creates new resource
33
     *
34
     * @param array $response The response
35
     */
36
    public function __construct(array $response = [])
37
    {
38
        $this->response = $response;
39
    }
40
41
    /**
42
     * Returns a value by key using dot notation
43
     *
44
     * @param string $key The key to look
45
     * @return mixed The value
46
     */
47
    public function get($key)
48
    {
49
        return $this->getValueByKey($this->response, $key);
50
    }
51
52
    /**
53
     * Return all data of the resource as an array.
54
     *
55
     * @return array The response converted into an array
56
     */
57
    public function toArray()
58
    {
59
        return $this->response;
60
    }
61
}
62