GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

FakeResponse   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 64
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 1
A buildResponse() 0 12 2
1
<?php
2
/**
3
 * FakeResponse.php
4
 *
5
 * @package Embera
6
 * @author Michael Pratt <[email protected]>
7
 * @link   http://www.michael-pratt.com/
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Embera;
14
15
/**
16
 * This class manages fake oembed responses
17
 */
18
class FakeResponse
19
{
20
    /** @var array Configuration Array */
21
    protected $config = array();
22
23
    /** @var array Array with default oembed data */
24
    protected $response = array(
25
        'version' => '1.0',
26
        'provider_name' => '',
27
        'url' => '',
28
        'title' => '',
29
        'author_name' => '',
30
        'author_url' => '',
31
        'cache_age' => 0,
32
        'embera_using_fake' => 1
33
    );
34
35
    /**
36
     * Construct
37
     *
38
     * @param array $config
39
     * @param array $response
40
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
41
     */
42 88
    public function __construct(array $config = array(), array $response = array())
43
    {
44 88
        $this->config = array_replace_recursive(array(
45
            'fake' => array(
46 88
                'width' => 420,
47
                'height' => 315
48 88
            ),
49
            'params' => array(
50 88
                'maxwidth' => 0,
51 88
                'maxheight' => 0,
52
            )
53 88
        ), $config);
54
55 88
        $this->config['fake']['width']  = max($this->config['fake']['width'], $this->config['params']['maxwidth']);
56 88
        $this->config['fake']['height'] = max($this->config['fake']['height'], $this->config['params']['maxheight']);
57 88
        unset($this->config['params']);
58
59 88
        $this->response = array_merge($this->response, $this->config['fake'], $response);
60 88
    }
61
62
    /**
63
     * Builds the fake response.
64
     * This replaces placeholders that are present in $config['fake']
65
     * into the response array
66
     *
67
     * @return array
68
     */
69 88
    public function buildResponse()
70
    {
71 88
        $return = array();
72 88
        foreach ($this->response as $k => $v)
73
        {
74 88
            $return[$k] = str_replace(array_map(function ($name){
75 88
                return '{' . $name . '}';
76 88
            }, array_keys($this->config['fake'])), array_values($this->config['fake']), $v);
77 88
        }
78
79 88
        return $return;
80
    }
81
}
82
83
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
84