Completed
Pull Request — development (#546)
by Nick
06:40
created

BlockService::remove()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Oc\Page;
4
5
use Oc\Repository\Exception\RecordsNotFoundException;
6
7
/**
8
 * Class BlockService
9
 *
10
 * @package Oc\Page
11
 */
12
class BlockService
13
{
14
    /**
15
     * @var BlockRepository
16
     */
17
    private $blockRepository;
18
19
    /**
20
     * BlockService constructor.
21
     *
22
     * @param BlockRepository $blockRepository
23
     */
24
    public function __construct(BlockRepository $blockRepository)
25
    {
26
        $this->blockRepository = $blockRepository;
27
    }
28
29
    /**
30
     * Fetch by.
31
     *
32
     * @param array $where
33
     *
34
     * @return BlockEntity[]
35
     */
36
    public function fetchBy(array $where = [])
37
    {
38
        try {
39
            $result = $this->blockRepository->fetchBy($where);
40
        } catch (RecordsNotFoundException $e) {
41
            $result = [];
42
        }
43
44
        return $result;
45
    }
46
47
    /**
48
     * Creates a page in the database.
49
     *
50
     * @param BlockEntity $entity
51
     *
52
     * @return BlockEntity
53
     */
54
    public function create(BlockEntity $entity)
55
    {
56
        return $this->blockRepository->create($entity);
57
    }
58
59
    /**
60
     * Update a page in the database.
61
     *
62
     * @param BlockEntity $entity
63
     *
64
     * @return BlockEntity
65
     */
66
    public function update(BlockEntity $entity)
67
    {
68
        return $this->blockRepository->update($entity);
69
    }
70
71
    /**
72
     * Removes a page from the database.
73
     *
74
     * @param BlockEntity $entity
75
     *
76
     * @return BlockEntity
77
     */
78
    public function remove(BlockEntity $entity)
79
    {
80
        return $this->blockRepository->remove($entity);
81
    }
82
}
83