Completed
Push — master ( 2a2adf...b9fc74 )
by Nate
50s
created

UrlCriteria::read()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 11
cp 0
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipbox/salesforce/blob/master/LICENSE.md
6
 * @link       https://github.com/flipbox/salesforce
7
 */
8
9
namespace Flipbox\Salesforce\Criteria;
10
11
use Flipbox\Salesforce\Resources\Url;
12
use Psr\Http\Message\ResponseInterface;
13
14
/**
15
 * @author Flipbox Factory <[email protected]>
16
 * @since 3.4.0
17
 */
18
class UrlCriteria extends AbstractCriteria
19
{
20
    use ConnectionTrait,
21
        CacheTrait;
22
23
    /**
24
     * @var string|null
25
     */
26
    protected $url;
27
28
    /**
29
     * @return string
30
     * @throws \Exception
31
     */
32
    public function getUrl(): string
33
    {
34
        if (null === ($url = $this->findUrl())) {
35
            throw new \Exception("Invalid Url");
36
        }
37
        return $url;
38
    }
39
40
    /**
41
     * @return string|null
42
     */
43
    public function findUrl()
44
    {
45
        return $this->url;
46
    }
47
48
    /**
49
     * @param string|null $url
50
     * @return $this
51
     */
52
    public function setUrl(string $url = null)
53
    {
54
        $this->url = $url;
55
        return $this;
56
    }
57
58
    /**
59
     * @param array $criteria
60
     * @param array $config
61
     * @return ResponseInterface
62
     * @throws \Exception
63
     */
64
    public function read(array $criteria = [], array $config = []): ResponseInterface
65
    {
66
        $this->populate($criteria);
67
68
        return Url::read(
69
            $this->getUrl(),
70
            $this->getConnection(),
71
            $this->getCache(),
72
            $this->getLogger(),
73
            $config
74
        );
75
    }
76
}
77