Completed
Push — master ( 118c60...254398 )
by Litera
03:47
created

ProgramVisitorsControl::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 1
rs 9.6666
1
<?php
2
3
namespace App\Components;
4
5
use App\Repositories\ProgramRepository;
6
7
class ProgramVisitorsControl extends BaseControl
8
{
9
10
	const TEMPLATE_NAME = 'ProgramVisitors';
11
12
	/**
13
	 * @var ProgramRepository
14
	 */
15
	private $programRepository;
16
17
	/**
18
	 * @param ProgramRepository $repository
19
	 */
20
	public function __construct(ProgramRepository $repository)
21
	{
22
		$this->setProgramRepository($repository);
23
	}
24
25
	/**
26
	 * @param  string $mealColumn
0 ignored issues
show
Bug introduced by
There is no parameter named $mealColumn. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
27
	 * @param  string $mealName
0 ignored issues
show
Bug introduced by
There is no parameter named $mealName. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
28
	 * @return void
29
	 */
30
	public function render(int $programId)
31
	{
32
		$template = $this->getTemplate();
33
		$template->setFile($this->buildTemplatePath());
34
		$template->imgDir = IMG_DIR;
0 ignored issues
show
Bug introduced by
Accessing imgDir 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...
35
		$template->programId = $programId;
0 ignored issues
show
Bug introduced by
Accessing programId 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...
36
		$template->visitors = $this->getProgramRepository()->findVisitors($programId);
0 ignored issues
show
Bug introduced by
Accessing visitors 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...
37
		$template->render();
38
	}
39
40
	/**
41
	 * @return ProgramRepository
42
	 */
43
	protected function getProgramRepository(): ProgramRepository
44
	{
45
		return $this->programRepository;
46
	}
47
48
	/**
49
	 * @param  ProgramRepository $repository
50
	 * @return self
51
	 */
52
	protected function setProgramRepository(ProgramRepository $repository): self
53
	{
54
		$this->programRepository = $repository;
55
56
		return $this;
57
	}
58
59
}
60