Completed
Pull Request — master (#102)
by Litera
11:03
created

BlocksByDayControl::getBlockModel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Components;
4
5
use App\Models\BlockModel;
6
7
class BlocksByDayControl extends BaseControl
8
{
9
10
	const TEMPLATE_NAME = 'BlocksByDay';
11
12
	/**
13
	 * @var ProgramsControl
14
	 */
15
	private $programs;
16
17
	/**
18
	 * @var BlockModel
19
	 */
20
	private $blockModel;
21
22
	/**
23
	 * @param BlockModel $model
24
	 */
25
	public function __construct(BlockModel $model, ProgramsControl $control)
26
	{
27
		$this->setBlockModel($model);
28
		$this->setProgramsControl($control);
29
	}
30
31
	/**
32
	 * @param  string $day
33
	 * @return void
34
	 */
35
	public function render($day)
36
	{
37
		$this->getBlockModel()->setMeetingId($this->getMeetingId());
38
		$blocks = $this->getBlockModel()->findByDay($day);
39
40
		$template = $this->getTemplate();
41
		$template->setFile($this->buildTemplatePath());
42
		$template->blocks = $blocks;
0 ignored issues
show
Bug introduced by
Accessing blocks 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...
43
		$template->render();
44
	}
45
46
	/**
47
	 * @return ProgramsControl
48
	 */
49
	protected function createComponentPrograms()
50
	{
51
		return $this->programs;
52
	}
53
54
	/**
55
	 * @param  ProgramsControl $control
56
	 * @return $this
57
	 */
58
	protected function setProgramsControl(ProgramsControl $control)
59
	{
60
		$this->programs = $control;
61
62
		return $this;
63
	}
64
65
	/**
66
	 * @return BlockModel
67
	 */
68
	protected function getBlockModel()
69
	{
70
		return  $this->blockModel;
71
	}
72
73
	/**
74
	 * @param  BlockModel $model
75
	 * @return $this
76
	 */
77
	protected function setBlockModel(BlockModel $model)
78
	{
79
		$this->blockModel = $model;
80
81
		return $this;
82
	}
83
84
}
85