Completed
Push — 7.0 ( 66fc99...d11e6e )
by André
14:26
created

ExceptionConversion::loadUrlDataByUrl()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 7

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 3
nop 1
dl 10
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Publish\Core\Persistence\Legacy\URL\Gateway;
8
9
use eZ\Publish\API\Repository\Values\URL\Query\Criterion;
10
use eZ\Publish\Core\Persistence\Legacy\URL\Gateway;
11
use eZ\Publish\SPI\Persistence\URL\URL;
12
use Doctrine\DBAL\DBALException;
13
use PDOException;
14
use RuntimeException;
15
16
class ExceptionConversion extends Gateway
17
{
18
    /**
19
     * The wrapped gateway.
20
     *
21
     * @var Gateway
22
     */
23
    protected $innerGateway;
24
25
    /**
26
     * ExceptionConversion constructor.
27
     *
28
     * @param \eZ\Publish\Core\Persistence\Legacy\URL\Gateway $innerGateway
29
     */
30
    public function __construct(Gateway $innerGateway)
31
    {
32
        $this->innerGateway = $innerGateway;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 View Code Duplication
    public function updateUrl(URL $url)
39
    {
40
        try {
41
            return $this->innerGateway->updateUrl($url);
42
        } catch (DBALException $e) {
43
            throw new RuntimeException('Database error', 0, $e);
44
        } catch (PDOException $e) {
45
            throw new RuntimeException('Database error', 0, $e);
46
        }
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52 View Code Duplication
    public function find(Criterion $criterion, $offset, $limit, array $sortClauses = [], $doCount = true)
53
    {
54
        try {
55
            return $this->innerGateway->find($criterion, $offset, $limit, $sortClauses, $doCount);
56
        } catch (DBALException $e) {
57
            throw new RuntimeException('Database error', 0, $e);
58
        } catch (PDOException $e) {
59
            throw new RuntimeException('Database error', 0, $e);
60
        }
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66 View Code Duplication
    public function findUsages($id)
67
    {
68
        try {
69
            return $this->innerGateway->findUsages($id);
70
        } catch (DBALException $e) {
71
            throw new RuntimeException('Database error', 0, $e);
72
        } catch (PDOException $e) {
73
            throw new RuntimeException('Database error', 0, $e);
74
        }
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80 View Code Duplication
    public function loadUrlData($id)
81
    {
82
        try {
83
            return $this->innerGateway->loadUrlData($id);
84
        } catch (DBALException $e) {
85
            throw new RuntimeException('Database error', 0, $e);
86
        } catch (PDOException $e) {
87
            throw new RuntimeException('Database error', 0, $e);
88
        }
89
    }
90
91
    /**
92
     * {@inheritdoc}
93
     */
94 View Code Duplication
    public function loadUrlDataByUrl($url)
95
    {
96
        try {
97
            return $this->innerGateway->loadUrlDataByUrl($url);
98
        } catch (DBALException $e) {
99
            throw new RuntimeException('Database error', 0, $e);
100
        } catch (PDOException $e) {
101
            throw new RuntimeException('Database error', 0, $e);
102
        }
103
    }
104
}
105