Completed
Push — development ( eb9524...db4517 )
by Andrij
28:49 queued 02:09
created

BannerView   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 39
rs 10
c 2
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getBanner() 0 3 1
A show() 0 6 1
A render() 0 3 1
1
<?php
2
3
namespace xbanners\src\Entities;
4
5
use xbanners\models\Banners;
6
7
class BannerView
8
{
0 ignored issues
show
introduced by
Opening brace of a class must be on the same line as the definition
Loading history...
9
10
    /**
11
     * @var \Banners\Models\Banners
12
     */
13
    protected $banner;
14
15
    /**
16
     * @param Banners $banner
17
     */
18
    public function __construct(Banners $banner) {
19
        $this->banner = $banner;
0 ignored issues
show
Documentation Bug introduced by
$banner is of type object<xbanners\models\Banners>, but the property $banner was declared to be of type object<Banners\Models\Banners>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof 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 given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
20
    }
21
22
    /**
23
     * @return Banners
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use \Banners\Models\Banners.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
24
     */
25
    public function getBanner() {
26
        return $this->banner;
27
    }
28
29
    /**
30
     * @return string
31
     */
32
    public function show() {
33
        $data = [
34
            'banner' => $this->banner,
35
        ];
36
        return $this->render($data);
37
    }
38
39
    /**
40
     * @return string
41
     */
42
    protected function render($data) {
43
        return \Ci::$APP->load->module('xbanners')->show($data);
44
    }
45
46
}