Passed
Push — v3 ( 932184...c18a4a )
by Andrew
16:41 queued 09:38
created

ServicesTrait::getEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Retour plugin for Craft CMS
4
 *
5
 * Retour allows you to intelligently redirect legacy URLs, so that you don't
6
 * lose SEO value when rebuilding & restructuring a website
7
 *
8
 * @link      https://nystudio107.com/
0 ignored issues
show
Coding Style introduced by
The tag in position 1 should be the @copyright tag
Loading history...
9
 * @copyright Copyright (c) 2018 nystudio107
0 ignored issues
show
Coding Style introduced by
@copyright tag must contain a year and the name of the copyright holder
Loading history...
10
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
11
12
namespace nystudio107\retour\services;
13
14
use craft\helpers\ArrayHelper;
15
use nystudio107\pluginvite\services\VitePluginService;
16
use nystudio107\retour\assetbundles\retour\RetourAsset;
17
use yii\base\InvalidConfigException;
18
19
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
20
 * @author    nystudio107
0 ignored issues
show
Coding Style introduced by
The tag in position 1 should be the @package tag
Loading history...
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
Coding Style introduced by
Tag value for @author tag indented incorrectly; expected 2 spaces but found 4
Loading history...
21
 * @package   Retour
0 ignored issues
show
Coding Style introduced by
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
22
 * @since     3.2.3
0 ignored issues
show
Coding Style introduced by
The tag in position 3 should be the @author tag
Loading history...
Coding Style introduced by
Tag value for @since tag indented incorrectly; expected 3 spaces but found 5
Loading history...
23
 *
24
 * @property Events $events
25
 * @property Redirects $redirects
26
 * @property Statistics $statistics
27
 * @property VitePluginService $vite
28
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
29
trait ServicesTrait
30
{
31
    // Public Methods
32
    // =========================================================================
33
34
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
Parameter $id should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $parent should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $config should have a doc-comment as per coding-style.
Loading history...
35
     * @inheritdoc
36
     */
37
    public function __construct($id, $parent = null, array $config = [])
38
    {
39
        // Merge in the passed config, so it our config can be overridden by Plugins::pluginConfigs['vite']
40
        // ref: https://github.com/craftcms/cms/issues/1989
41
        $config = ArrayHelper::merge([
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
42
            'components' => [
43
                'events' => Events::class,
44
                'redirects' => Redirects::class,
45
                'statistics' => Statistics::class,
46
                // Register the vite service
47
                'vite' => [
48
                    'class' => VitePluginService::class,
49
                    'assetClass' => RetourAsset::class,
50
                    'useDevServer' => true,
51
                    'devServerPublic' => 'http://localhost:3001',
52
                    'serverPublic' => 'http://localhost:8000',
53
                    'errorEntry' => 'src/js/Retour.js',
54
                    'devServerInternal' => 'http://craft-retour-buildchain:3001',
55
                    'checkDevServer' => true,
56
                ],
57
            ]
58
        ], $config);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
59
60
        parent::__construct($id, $parent, $config);
61
    }
62
63
    /**
64
     * Returns the events service
65
     *
66
     * @return Events The events service
67
     * @throws InvalidConfigException
68
     */
69
    public function getEvents(): Events
70
    {
71
        return $this->get('events');
0 ignored issues
show
Bug introduced by
It seems like get() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

71
        return $this->/** @scrutinizer ignore-call */ get('events');
Loading history...
72
    }
73
74
    /**
75
     * Returns the redirects service
76
     *
77
     * @return Redirects The redirects service
78
     * @throws InvalidConfigException
79
     */
80
    public function getRedirects(): Redirects
81
    {
82
        return $this->get('redirects');
83
    }
84
85
    /**
86
     * Returns the statistics service
87
     *
88
     * @return Statistics The statistics service
89
     * @throws InvalidConfigException
90
     */
91
    public function getStatistics(): Statistics
92
    {
93
        return $this->get('statistics');
94
    }
95
96
    /**
97
     * Returns the vite service
98
     *
99
     * @return VitePluginService The vite service
100
     * @throws InvalidConfigException
101
     */
102
    public function getVite(): VitePluginService
103
    {
104
        return $this->get('vite');
105
    }
106
}
107