SubCategoriesRepository   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 34
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getModel() 0 4 1
A findBySlug() 0 8 1
A getSubCategory() 0 8 1
1
<?php
2
3
namespace App\Repositories;
4
5
use App\SubCategory;
6
7
class SubCategoriesRepository extends Repository
8
{
9
    /**
10
     * @return SubCategory
11
     */
12
    public function getModel()
13
    {
14
        return new SubCategory();
15
    }
16
17
    /**
18
     * Get row by translated slug.
19
     *
20
     * @param $slug
21
     * @return mixed
22
     */
23
    public function findBySlug($slug)
24
    {
25
        return self::getModel()
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<App\SubCategory>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
26
            ->select('*')
27
            ->translated()
28
            ->whereSlug($slug)
29
            ->first();
30
    }
31
32
    public function getSubCategory($category_id)
33
    {
34
        return self::getModel()
0 ignored issues
show
Documentation Bug introduced by
The method select does not exist on object<App\SubCategory>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
35
            ->select('*')
36
            ->translated()
37
            ->whereCategoryId($category_id)
38
            ->get();
39
    }  
40
}