Passed
Push — v3 ( 2b006a...43f239 )
by Andrew
33:34 queued 16:32
created

src/controllers/ApiController.php (26 issues)

1
<?php
2
/**
3
 * Retour plugin for Craft CMS 3.x
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\controllers;
13
14
use nystudio107\retour\Retour;
15
use craft\web\Controller;
16
17
/**
0 ignored issues
show
Missing short description in doc comment
Loading history...
18
 * @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...
19
 * @package   Retour
0 ignored issues
show
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
20
 * @since     3.1.39
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
 */
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...
22
class ApiController extends Controller
23
{
24
    // Constants
25
    // =========================================================================
26
27
    // Protected Properties
28
    // =========================================================================
29
30
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
31
     * @inheritdoc
32
     */
33
    protected $allowAnonymous = [
34
        'get-redirects',
35
    ];
36
37
    // Public Methods
38
    // =========================================================================
39
40
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
Parameter $action should have a doc-comment as per coding-style.
Loading history...
41
     * @inheritDoc
42
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
43
    public function beforeAction($action)
44
    {
45
        if (!Retour::$settings->enableApiEndpoint) {
46
            $this->allowAnonymous = false;
47
        }
48
49
        return parent::beforeAction($action);
50
    }
51
52
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
53
     * @param null $siteId
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $siteId is correct as it would always require null to be passed?
Loading history...
Missing parameter comment
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
54
     * @return \yii\web\Response
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
55
     */
56
    public function actionGetRedirects($siteId = null)
57
    {
58
        $redirects = Retour::$plugin->redirects->getAllStaticRedirects(null, $siteId);
59
60
        return $this->asJson($redirects ?? []);
61
    }
62
}
63