Completed
Push — master ( d6bb8e...21b718 )
by Oleg
05:17
created

View   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
1
<?php
2
3
namespace App\Components;
4
5
use Micro\Base\IContainer;
6
use Micro\Mvc\Views\PhpView;
7
8
/**
9
 * Class View
10
 *
11
 * @package App\Components
12
 */
13
class View extends PhpView
14
{
15
    public $title = 'Micro';
16
    public $menu = ['<a href="/">Главная</a>', '<a href="/blog/post">Блог</a>'];
17
    public $user = [];
18
19
    /**
20
     * View constructor.
21
     * @param IContainer $container
22
     */
23
    public function __construct(IContainer $container)
24
    {
25
        parent::__construct($container);
26
27
        if (!$this->container->user->isGuest()) {
0 ignored issues
show
Bug introduced by
Accessing user on the interface Micro\Base\IContainer 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...
28
            $this->user[] = '<a href="/profile">Профиль</a>';
29
            $this->user[] = ' (<a href="/logout">Выйти</a>)';
30
        } else {
31
            $this->user[] = '<a href="/login">Войти</a>';
32
            $this->user[] = '<a href="/register">Регистрация</a>';
33
        }
34
    }
35
} 
36