ShopCategory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 57
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 57
loc 57
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A store() 9 9 1
A getCategoryAttribute() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace App\Models;
4
5
/**
6
 * Class ShopCategory.
7
 */
8 View Code Duplication
class ShopCategory extends ChocolateyModel
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * Disable Timestamps.
12
     *
13
     * @var bool
14
     */
15
    public $timestamps = false;
16
17
    /**
18
     * The table associated with the model.
19
     *
20
     * @var string
21
     */
22
    protected $table = 'chocolatey_shop_items_categories';
23
24
    /**
25
     * Primary Key of the Table.
26
     *
27
     * @var string
28
     */
29
    protected $primaryKey = 'category_name';
30
31
    /**
32
     * The Appender(s) of the Model.
33
     *
34
     * @var array
35
     */
36
    protected $appends = ['category'];
37
38
    /**
39
     * Store an Shop Country.
40
     *
41
     * @param string $categoryName
42
     *
43
     * @return ShopCategory
44
     */
45
    public function store(string $categoryName): ShopCategory
46
    {
47
        $this->attributes['category_name'] = $categoryName;
48
        $this->timestamps = false;
49
50
        $this->save();
51
52
        return $this;
53
    }
54
55
    /**
56
     * Get Shop Category Name.
57
     *
58
     * @return string
59
     */
60
    public function getCategoryAttribute(): string
61
    {
62
        return $this->attributes['category_name'];
63
    }
64
}
65