ControllerExtension::CatalogueCategories()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 7
rs 10
1
<?php
2
3
namespace SilverCommerce\CatalogueFrontend\Extensions;
4
5
use SilverStripe\Core\Extension;
6
use SilverCommerce\CatalogueAdmin\Model\CatalogueProduct;
7
use SilverCommerce\CatalogueAdmin\Model\CatalogueCategory;
8
9
/**
10
 * Extension for Controller that provide additional methods to all
11
 * templates 
12
 *
13
 * @author  i-lateral (http://www.i-lateral.com)
14
 * @package catalogue
15
 */
16
class ControllerExtension extends Extension
17
{
18
    /**
19
     * Gets a list of all Categories, either top level (default) or
20
     * from a sub level
21
     *
22
     * @param Parent the ID of a parent cetegory
0 ignored issues
show
Bug introduced by
The type SilverCommerce\CatalogueFrontend\Extensions\the 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...
23
     *
24
     * @return SS_List
0 ignored issues
show
Bug introduced by
The type SilverCommerce\Catalogue...tend\Extensions\SS_List 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...
25
     */
26
    public function CatalogueCategories($ParentID = 0)
27
    {
28
        return CatalogueCategory::get()
29
            ->filter(
30
                [
31
                "ParentID" => $ParentID,
32
                "Disabled" => 0
33
                ]
34
            );
35
    }
36
37
    /**
38
     * Generate a list of categories that can be used in menus
39
     * (this means that) categories are checked for their
40
     * can view state before being returned
41
     * 
42
     * @param Parent the ID of a parent cetegory
43
     *
44
     * @return SS_List
45
     */
46
    public function CatalogueMenu($ParentID = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $ParentID is not used and could be removed. ( Ignorable by Annotation )

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

46
    public function CatalogueMenu(/** @scrutinizer ignore-unused */ $ParentID = 0)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
47
    {
48
        return $this
49
            ->owner
50
            ->CatalogueCategories()
51
            ->filterByCallback(
52
                function ($item, $list) {
0 ignored issues
show
Unused Code introduced by
The parameter $list is not used and could be removed. ( Ignorable by Annotation )

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

52
                function ($item, /** @scrutinizer ignore-unused */ $list) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
53
                    return $item->canView();
54
                }
55
            );
56
    }
57
58
    /**
59
     * Get a full list of products, filtered by a category if provided.
60
     *
61
     * @param ParentCategoryID the ID of the parent category
62
     */
63
    public function CatalogueProducts($ParentCategoryID = 0)
64
    {
65
        return CatalogueProduct::get()
66
            ->filter(
67
                [
68
                "ParentID" => $ParentCategoryID,
69
                "Disabled" => 0
70
                ]
71
            );
72
    }
73
}