HtmlBlockRepository   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A selectOneByShopIdAndPosition() 0 8 2
A selectAllActiveByShopId() 0 3 1
A selectOneByShopIdAndSlug() 0 8 2
A __construct() 0 3 1
1
<?php
2
3
namespace Hideyo\Ecommerce\Framework\Services\HtmlBlock\Entity;
4
5
use Hideyo\Ecommerce\Framework\Services\HtmlBlock\Entity\HtmlBlock;
6
use Hideyo\Ecommerce\Framework\Services\BaseRepository;
7
8
class HtmlBlockRepository extends BaseRepository 
9
{
10
    protected $model;
11
12
    public function __construct(HtmlBlock $model)
13
    {
14
        $this->model = $model;
15
    }
16
17
    function selectAllActiveByShopId($shopId)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
18
    {
19
         return $this->model->where('shop_id', $shopId)->get();
20
    }
21
22
    function selectOneByShopIdAndSlug($shopId, $slug)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
23
    {
24
        $result = $this->model->where('shop_id', $shopId)->where('slug', $slug)->get();
25
        
26
        if ($result->isEmpty()) {
27
            return false;
28
        }
29
        return $result->first();
30
    }
31
32
    public function selectOneByShopIdAndPosition($position, $shopId)
33
    {
34
        $result = $this->model->where('shop_id', $shopId)->where('position', $position)->get();
35
        
36
        if ($result->isEmpty()) {
37
            return false;
38
        }
39
        return $result->first();
40
    } 
41
}