Issues (447)

src/variables/RouteMapVariable.php (97 issues)

1
<?php
2
/**
3
 * Route Map plugin for Craft CMS
4
 *
5
 * Returns a list of public routes for elements with URLs
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) 2017 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\routemap\variables;
12
13
use craft\base\ElementInterface;
0 ignored issues
show
The type craft\base\ElementInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use nystudio107\routemap\RouteMap;
15
16
/**
0 ignored issues
show
Missing short description in doc comment
Loading history...
17
 * @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...
18
 * @package   RouteMap
0 ignored issues
show
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
19
 * @since     1.0.0
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...
20
 */
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...
21
class RouteMapVariable
22
{
23
    // Public Methods
24
    // =========================================================================
25
    /**
26
     * Return the public URLs for all elements that have URLs
27
     *
28
     * @param array $criteria
0 ignored issues
show
Missing parameter comment
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
29
     * @param ?int $siteId
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 2 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
30
     * @return array
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
31
     */
32
    public function getAllUrls(array $criteria = [], ?int $siteId = null): array
33
    {
34
        return RouteMap::$plugin->routes->getAllUrls($criteria, $siteId);
35
    }
36
37
    /**
38
     * Return all the section and category route rules
39
     *
40
     * @param string $format 'Craft'|'React'|'Vue'
0 ignored issues
show
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
41
     * @param ?int $siteId
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 3 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
42
     * @return array
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
43
     */
44
    public function getAllRouteRules(string $format = 'Craft', ?int $siteId = null): array
45
    {
46
        return RouteMap::$plugin->routes->getAllRouteRules($format, $siteId);
47
    }
48
49
50
    /**
51
     * Return the public URLs for a section
52
     *
53
     * @param string $section
0 ignored issues
show
Missing parameter comment
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
54
     * @param array $criteria
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 2 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
55
     * @param ?int $siteId
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 3 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
56
     * @return array
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
57
     */
58
    public function getSectionUrls(string $section, array $criteria = [], ?int $siteId = null): array
59
    {
60
        return RouteMap::$plugin->routes->getSectionUrls($section, $criteria, $siteId);
61
    }
62
63
64
    /**
65
     * Return all the section route rules
66
     *
67
     * @param string $format 'Craft'|'React'|'Vue'
0 ignored issues
show
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
68
     * @param ?int $siteId
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 3 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
69
     * @return array
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
70
     */
71
    public function getAllSectionRouteRules(string $format = 'Craft', ?int $siteId = null): array
72
    {
73
        return RouteMap::$plugin->routes->getAllSectionRouteRules($format, $siteId);
74
    }
75
76
    /**
77
     * Return the route rules for a specific section
78
     *
79
     * @param string $section
0 ignored issues
show
Missing parameter comment
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
80
     * @param string $format 'Craft'|'React'|'Vue'
0 ignored issues
show
Expected 2 spaces after parameter name; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
81
     * @param ?int $siteId
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 3 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
82
     * @return array
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
83
     */
84
    public function getSectionRouteRules(string $section, string $format = 'Craft', ?int $siteId = null): array
85
    {
86
        return RouteMap::$plugin->routes->getSectionRouteRules($section, $format, $siteId);
87
    }
88
89
    /**
90
     * Return the public URLs for a category group
91
     *
92
     * @param string $category
0 ignored issues
show
Missing parameter comment
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
93
     * @param array $criteria
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 2 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
94
     * @param ?int $siteId
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 3 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
95
     * @return array
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
96
     */
97
    public function getCategoryUrls(string $category, array $criteria = [], ?int $siteId = null): array
98
    {
99
        return RouteMap::$plugin->routes->getCategoryUrls($category, $criteria, $siteId);
100
    }
101
102
    /**
103
     * Return all the cateogry group route rules
104
     *
105
     * @param string $format 'Craft'|'React'|'Vue'
0 ignored issues
show
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
106
     * @param ?int $siteId
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 3 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
107
     * @return array
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
108
     */
109
    public function getAllCategoryRouteRules(string $format = 'Craft', ?int $siteId = null): array
110
    {
111
        return RouteMap::$plugin->routes->getAllCategoryRouteRules($format, $siteId);
112
    }
113
114
    /**
115
     * Return the route rules for a specific category
116
     *
117
     * @param string $category
0 ignored issues
show
Missing parameter comment
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
118
     * @param string $format 'Craft'|'React'|'Vue'
0 ignored issues
show
Expected 3 spaces after parameter name; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
119
     * @param ?int $siteId
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 3 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
120
     * @return array
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
121
     */
122
    public function getCategoryRouteRules(string $category, string $format = 'Craft', ?int $siteId = null): array
123
    {
124
        return RouteMap::$plugin->routes->getCategoryRouteRules($category, $format, $siteId);
125
    }
126
127
128
    /**
129
     * Get all the assets of the type $assetTypes that are used in the Entry
130
     * that matches the $url
131
     *
132
     * @param string $url
0 ignored issues
show
Missing parameter comment
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
133
     * @param array $assetTypes
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 2 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
134
     * @param ?int $siteId
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 3 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
135
     * @return array
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
136
     */
137
    public function getUrlAssetUrls(string $url, array $assetTypes = ['image'], ?int $siteId = null): array
138
    {
139
        return RouteMap::$plugin->routes->getUrlAssetUrls($url, $assetTypes, $siteId);
140
    }
141
142
    /**
143
     * Returns all the URLs for the given $elementType based on the passed in
144
     * $criteria and $siteId
145
     *
146
     * @param string|ElementInterface $elementType
0 ignored issues
show
Missing parameter comment
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
147
     * @param array $criteria
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 19 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
148
     * @param ?int $siteId
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 20 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
149
     * @return array
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
150
     */
151
    public function getElementUrls(string|ElementInterface $elementType, array $criteria = [], ?int $siteId = null): array
152
    {
153
        return RouteMap::$plugin->routes->getElementUrls($elementType, $criteria, $siteId);
154
    }
155
156
    /**
157
     * Get all routes rules defined in the config/routes.php file and CMS
158
     *
159
     * @param bool $incGlobalRules - merge global routes with the site rules
0 ignored issues
show
Doc comment for parameter $incGlobalRules does not match actual variable name $siteId
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
160
     * @param ?int $siteId
0 ignored issues
show
Missing parameter comment
Loading history...
Doc comment for parameter $siteId does not match actual variable name $incGlobalRules
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
161
     * @return array
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
162
     */
163
    public function getRouteRules(?int $siteId = null, bool $incGlobalRules = true): array
164
    {
165
        return RouteMap::$plugin->routes->getRouteRules($siteId, $incGlobalRules);
166
    }
167
}
168