UseDevDashboard   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 3
Bugs 1 Features 1
Metric Value
wmc 3
eloc 10
c 3
b 1
f 1
dl 0
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A aroundGetStartupPageUrl() 0 12 2
1
<?php
2
3
namespace Firegento\DevDashboard\Plugin;
4
5
use Firegento\DevDashboard\Model\Config;
6
7
class UseDevDashboard
8
{
9
10
    /** @var \Magento\Backend\Model\Auth\Session */
11
    protected $_authSession;
12
13
    /** @var \Firegento\DevDashboard\Api\ConfigRepositoryInterface */
14
    protected $_configRepository;
15
16
    /**
17
     * @param \Magento\Backend\Model\Auth\Session $authSession
18
     * @param \Firegento\DevDashboard\Api\ConfigRepositoryInterface $configRepositoryInterface
19
     */
20
    public function __construct(
21
        \Magento\Backend\Model\Auth\Session $authSession,
22
        \Firegento\DevDashboard\Api\ConfigRepositoryInterface $configRepository
23
    ) {
24
        $this->_authSession = $authSession;
25
        $this->_configRepository = $configRepository;
26
    }
27
28
    /**
29
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
30
     * @param \Magento\Backend\Model\Url $subject
31
     * @param callable $callable
32
     * @return string
33
     */
34
    public function aroundGetStartupPageUrl(\Magento\Backend\Model\Url $subject, callable $callable)
0 ignored issues
show
Unused Code introduced by
The parameter $subject is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

34
    public function aroundGetStartupPageUrl(/** @scrutinizer ignore-unused */ \Magento\Backend\Model\Url $subject, callable $callable)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
35
    {
36
37
        $userId = $this->_authSession->getUser()->getId();
38
39
        /** @var Config $config */
40
        $config = $this->_configRepository->getByUserId($userId);
41
        if ($config->getData('use_devdashboard')) {
42
            return 'devdashboard/index/index';
43
        }
44
45
        return $callable();
46
    }
47
}
48