Passed
Pull Request — master (#92)
by Fèvre
13:40 queued 08:22
created

ShopItemRepository::create()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 10
rs 10
1
<?php
2
3
namespace Xetaravel\Models\Repositories;
4
5
use Illuminate\Support\Collection;
6
use Xetaravel\Models\ShopItem;
7
8
class ShopItemRepository
9
{
10
    /**
11
     * Find the latest shop items for the sidebar.
12
     *
13
     * @return \Illuminate\Database\Eloquent\Collection
14
     */
15
    public static function sidebar(): Collection
16
    {
17
        return ShopItem::latest()->take(config('xetaravel.shop.items_sidebar'))->get();
18
    }
19
20
    /**
21
     * Create the new article and save it.
22
     *
23
     * @param array $data The data used to create the article.
24
     *
25
     * @return \Xetaravel\Models\ShopItem
26
     */
27
    public static function create(array $data): ShopItem
28
    {
29
        return ShopItem::create([
30
            'title' => $data['title'],
31
            'shop_category_id' => $data['shop_category_id'],
32
            'is_display' => isset($data['is_display']) ? true : false,
33
            'content' => $data['content'],
34
            'price' => $data['price'],
35
            'discount' => $data['discount'],
36
            'quantity' => $data['quantity'],
37
        ]);
38
    }
39
40
    /**
41
     * Update the shop item data and save it.
42
     *
43
     * @param array $data The data used to update the shop item.
44
     * @param \Xetaravel\Models\ShopItem $item The shop item to update.
45
     *
46
     * @return \Xetaravel\Models\ShopItem
47
     */
48
    public static function update(array $data, ShopItem $item): ShopItem
0 ignored issues
show
Unused Code introduced by
The parameter $data 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

48
    public static function update(/** @scrutinizer ignore-unused */ array $data, ShopItem $item): ShopItem

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...
Unused Code introduced by
The parameter $item 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

48
    public static function update(array $data, /** @scrutinizer ignore-unused */ ShopItem $item): ShopItem

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...
49
    {
50
    }
51
}
52