Issues (1783)

src/services/ServicesTrait.php (20 issues)

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
The tag in position 1 should be the @copyright tag
Loading history...
9
 * @copyright Copyright (c) 2018 nystudio107
0 ignored issues
show
@copyright tag must contain a year and the name of the copyright holder
Loading history...
10
 */
0 ignored issues
show
PHP version not specified
Loading history...
Missing @category tag in file comment
Loading history...
Missing @package tag in file comment
Loading history...
Missing @author tag in file comment
Loading history...
Missing @license tag in file comment
Loading history...
11
12
namespace nystudio107\retour\services;
13
14
use nystudio107\pluginvite\services\VitePluginService;
15
use nystudio107\retour\assetbundles\retour\RetourAsset;
16
use yii\base\InvalidConfigException;
17
18
/**
0 ignored issues
show
Missing short description in doc comment
Loading history...
19
 * @author    nystudio107
0 ignored issues
show
The tag in position 1 should be the @package tag
Loading history...
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
Tag value for @author tag indented incorrectly; expected 2 spaces but found 4
Loading history...
20
 * @package   Retour
0 ignored issues
show
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
21
 * @since     4.1.4
0 ignored issues
show
The tag in position 3 should be the @author tag
Loading history...
Tag value for @since tag indented incorrectly; expected 3 spaces but found 5
Loading history...
22
 *
23
 * @property Events $events
24
 * @property Redirects $redirects
25
 * @property Statistics $statistics
26
 * @property VitePluginService $vite
27
 */
0 ignored issues
show
Missing @category tag in class comment
Loading history...
Missing @license tag in class comment
Loading history...
Missing @link tag in class comment
Loading history...
28
trait ServicesTrait
29
{
30
    // Public Static Methods
31
    // =========================================================================
32
33
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
34
     * @inheritdoc
35
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
36
    public static function config(): array
37
    {
38
        // Constants aren't allowed in traits until PHP >= 8.2, and config() is called before __construct(),
39
        // so we can't extract it from the passed in $config
40
        $majorVersion = '5';
41
        // Dev server container name & port are based on the major version of this plugin
42
        $devPort = 3000 + (int)$majorVersion;
43
        $versionName = 'v' . $majorVersion;
44
        return [
45
            'components' => [
46
                'events' => Events::class,
47
                'redirects' => Redirects::class,
48
                'statistics' => Statistics::class,
49
                // Register the vite service
50
                'vite' => [
51
                    'assetClass' => RetourAsset::class,
52
                    'checkDevServer' => true,
53
                    'class' => VitePluginService::class,
54
                    'devServerInternal' => 'http://craft-retour-' . $versionName . '-buildchain-dev:' . $devPort,
55
                    'devServerPublic' => 'http://localhost:' . $devPort,
56
                    'errorEntry' => 'src/js/Retour.js',
57
                    'useDevServer' => true,
58
                ],
59
            ],
60
        ];
61
    }
62
63
    // Public Methods
64
    // =========================================================================
65
66
    /**
67
     * Returns the events service
68
     *
69
     * @return Events The events service
70
     * @throws InvalidConfigException
71
     */
72
    public function getEvents(): Events
73
    {
74
        return $this->get('events');
0 ignored issues
show
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

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