Completed
Push — develop ( a791bf...3a1732 )
by
unknown
17:30 queued 08:09
created

PreviewLink   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setViewHelper() 0 5 1
A getViewHelper() 0 4 1
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
7
 * @license   MIT
8
 * @author    [email protected]
9
 */
10
namespace Jobs\Form;
11
12
use Zend\Form\Element;
13
use Core\Form\ViewPartialProviderInterface;
14
use Core\Form\Element\ViewHelperProviderInterface;
15
16
//  implements ViewPartialProviderInterface
17
18
class PreviewLink extends Element implements ViewHelperProviderInterface
19
{
20
    protected $attributes = array(
21
        'type' => 'previewLink',
22
    );
23
24
    protected $helper = 'jobPreviewLink';
25
26
    /**
27
     * @param string|\Zend\View\Helper\HelperInterface $helper
28
     * @return $this|ViewHelperProviderInterface
29
     */
30
    public function setViewHelper($helper)
31
    {
32
        $this->helper = $helper;
0 ignored issues
show
Documentation Bug introduced by
It seems like $helper can also be of type object<Zend\View\Helper\HelperInterface>. However, the property $helper is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
33
        return $this;
34
    }
35
36
    /**
37
     * @return string|\Zend\View\Helper\HelperInterface
38
     */
39
    public function getViewHelper()
40
    {
41
        return $this->helper;
42
    }
43
}
44