Completed
Push — master ( fea2cb...118c60 )
by Litera
21s
created

AProgramOverviewControl   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 11 1
A createComponentBlocksByDay() 0 4 1
A setBlocksBayControl() 0 6 1
1
<?php
2
3
namespace App\Components;
4
5
use App\Components\ProgramsControl;
6
7
abstract class AProgramOverviewControl extends BaseControl implements IProgramOverviewControl
8
{
9
10
	const TEMPLATE_NAME = '';
11
12
	/**
13
	 * @var BlocksByDayControl
14
	 */
15
	private $blocksByDay;
16
17
	/**
18
	 * @return void
19
	 */
20
	public function render()
21
	{
22
		$template = $this->getTemplate();
23
		$template->setFile($this->buildTemplatePath());
24
		$template->weekendDays = [
0 ignored issues
show
Bug introduced by
Accessing weekendDays on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
25
			'pátek',
26
			'sobota',
27
			'neděle'
28
		];
29
		$template->render();
30
	}
31
32
	/**
33
	 * @return BlocksByDayControl
34
	 */
35
	protected function createComponentBlocksByDay(): IBlocksByDayControl
36
	{
37
		return $this->blocksByDay->setMeetingId($this->getMeetingId());
38
	}
39
40
	/**
41
	 * @param  BlocksByDayControl $control
42
	 * @return self
43
	 */
44
	protected function setBlocksBayControl(IBlocksByDayControl $control): self
45
	{
46
		$this->blocksByDay = $control;
0 ignored issues
show
Documentation Bug introduced by
$control is of type object<App\Components\IBlocksByDayControl>, but the property $blocksByDay was declared to be of type object<App\Components\BlocksByDayControl>. 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...
47
48
		return $this;
49
	}
50
51
}
52