RegistrationGraphControl::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
namespace App\Components;
4
5
use App\Models\ExportModel;
6
7
class RegistrationGraphControl extends BaseControl
8
{
9
10
	const TEMPLATE_NAME = 'RegistrationGraph';
11
	const GRAPH_WIDTH = 94;
12
	const GRAPH_HEIGHT_INIT = 0;
13
	const GRAPH_HEIGHT_STEP = 21.5;
14
	const GRAPH_HEIGHT_MIN = 310;
15
16
	/**
17
	 * @var ExportModel
18
	 */
19
	private $exportModel;
20
21
	/**
22
	 * @param ExportModel $model
23
	 */
24
	public function __construct(ExportModel $model)
25
	{
26
		$this->setExportModel($model);
27
	}
28
29
	/**
30
	 * @return void
31
	 */
32
	public function render()
33
	{
34
		$exportModel = $this->getExportModel();
35
36
		$template = $this->getTemplate();
37
		$template->setFile($this->buildTemplatePath());
38
		$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...
39
		$template->graph = $exportModel->graph();
0 ignored issues
show
Bug introduced by
Accessing graph 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...
40
		$template->graphMax = $exportModel->graphMax();
0 ignored issues
show
Bug introduced by
Accessing graphMax 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...
41
		$template->graphWidth = static::GRAPH_WIDTH;
0 ignored issues
show
Bug introduced by
Accessing graphWidth 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...
42
		$template->graphHeight = static::GRAPH_HEIGHT_INIT;
0 ignored issues
show
Bug introduced by
Accessing graphHeight 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->graphHeightStep = static::GRAPH_HEIGHT_STEP;
0 ignored issues
show
Bug introduced by
Accessing graphHeightStep 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...
44
		$template->render();
45
	}
46
47
	/**
48
	 * @return ExportModel
49
	 */
50
	protected function getExportModel()
51
	{
52
		return $this->exportModel->setMeetingId($this->getMeetingId());
53
	}
54
55
	/**
56
	 * @param  ExportModel $model
57
	 * @return $this
58
	 */
59
	protected function setExportModel(ExportModel $model)
60
	{
61
		$this->exportModel = $model;
62
63
		return $this;
64
	}
65
66
}
67