Issues (304)

src/services/ServicesTrait.php (20 issues)

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

69
        return $this->/** @scrutinizer ignore-call */ get('transcode');
Loading history...
70
    }
71
72
    /**
73
     * Returns the vite service
74
     *
75
     * @return VitePluginService The vite service
76
     * @throws InvalidConfigException
77
     */
78
    public function getVite(): VitePluginService
79
    {
80
        return $this->get('vite');
81
    }
82
}
83