GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

BlockController::Link()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 4
nop 1
1
<?php
2
3
namespace SheaDawson\Blocks\Controllers;
4
5
use SilverStripe\Control\Controller;
6
use SilverStripe\Control\Director;
7
8
/**
9
 * Block_Controller.
10
 *
11
 * @author Shea Dawson <[email protected]>
12
 */
13
class BlockController extends Controller
14
{
15
    /**
16
     * @var Block
17
     */
18
    protected $block;
19
20
    /**
21
     * @param Block $block
22
     */
23
    public function __construct($block = null)
24
    {
25
        if ($block) {
26
            $this->block = $block;
27
            $this->failover = $block;
0 ignored issues
show
Documentation Bug introduced by
It seems like $block of type object<SheaDawson\Blocks\Controllers\Block> is incompatible with the declared type object<SilverStripe\View\ViewableData> of property $failover.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
28
        }
29
30
        parent::__construct();
31
    }
32
33
    public function index()
34
    {
35
        return;
36
    }
37
38
    /**
39
     * @param string $action
40
     *
41
     * @return string
42
     */
43
    public function Link($action = null)
44
    {
45
        $id = ($this->block) ? $this->block->ID : null;
46
        $segment = Controller::join_links('block', $id, $action);
47
48
        if ($page = Director::get_current_page()) {
49
            return $page->Link($segment);
50
        }
51
52
        return Controller::curr()->Link($segment);
53
    }
54
55
    /**
56
     * @return string - link to page this block is on
57
     */
58
    public function pageLink()
59
    {
60
        $parts = explode('/block/', $this->Link());
61
62
        return isset($parts[0]) ? $parts[0] : null;
63
    }
64
65
    /**
66
     * @return Block
67
     */
68
    public function getBlock()
69
    {
70
        return $this->block;
71
    }
72
73
    /**
74
     * CSS Classes to apply to block element in template.
75
     *
76
     * @return string $classes
77
     */
78
    public function CSSClasses($stopAtClass = 'DataObject')
79
    {
80
        return $this->getBlock()->CSSClasses($stopAtClass);
81
    }
82
}
83