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.

Icon::render()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 4
nc 3
nop 1
1
<?php
2
/**
3
 * ZfTable ( Module for Zend Framework 2)
4
 *
5
 * @copyright Copyright (c) 2013 Piotr Duda [email protected]
6
 * @license   MIT License
7
 */
8
9
10
namespace ZfTable\Decorator\Cell;
11
12
use ZfTable\Decorator\Exception;
13
14
class Icon extends AbstractCellDecorator
15
{
16
17
    /**
18
     * Path to file
19
     * @var string
20
     */
21
    protected $path;
22
23
    /**
24
     * Alt attribute (optional)
25
     * @var string
26
     */
27
    protected $alt;
28
29
    /**
30
     * Place a decorator
31
     * @var null|string type
32
     */
33
    protected $place = null;
34
35
    /**
36
     *
37
     * @param array $options
38
     * @throws Exception\InvalidArgumentException
39
     */
40
    public function __construct(array $options = array())
41
    {
42
        if (!isset($options['path'])) {
43
            throw new Exception\InvalidArgumentException('path key in options argument required');
44
        }
45
        $this->path = $options['path'];
46
        $this->alt = (isset($options['alt'])) ? $options['alt'] : null;
47
        $this->place = (isset($options['place'])) ? $options['place'] : null;
48
    }
49
50
    /**
51
     * Rendering decorator
52
     * @param string $context
53
     * @return string
54
     */
55
    public function render($context)
56
    {
57
        if ($this->place || $this->place == self::RESET_CONTEXT) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->place of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
58
            return sprintf('<img src="%s" alt="%s" />', $this->path, $this->alt);
59
        } elseif ($this->place == self::PRE_CONTEXT) {
60
            return sprintf('<img src="%s" alt="%s" />', $this->path, $this->alt) . $context;
61
        } else {
62
            return $context . sprintf('<img src="%s" alt="%s" />', $this->path, $this->alt);
63
        }
64
    }
65
}
66