Url   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 60
ccs 0
cts 33
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A read() 0 15 1
A readRelay() 0 20 4
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\Resources;
10
11
use Flipbox\Relay\Salesforce\Builder\Resources\Url as RawBuilder;
12
use Flipbox\Salesforce\Connections\ConnectionInterface;
13
use Flipbox\Salesforce\Salesforce;
14
use Psr\Http\Message\ResponseInterface;
15
use Psr\Log\LoggerInterface;
16
use Psr\SimpleCache\CacheInterface;
17
18
/**
19
 * @author Flipbox Factory <[email protected]>
20
 * @since 3.4.0
21
 */
22
class Url
23
{
24
25
    /*******************************************
26
     * QUERY
27
     *******************************************/
28
29
    /**
30
     * @param ConnectionInterface|null $connection
31
     * @param CacheInterface|null $cache
32
     * @param string $url
33
     * @param LoggerInterface|null $logger
34
     * @param array $config
35
     * @return ResponseInterface
36
     */
37
    public static function read(
38
        string $url,
39
        ConnectionInterface $connection = null,
40
        CacheInterface $cache = null,
41
        LoggerInterface $logger = null,
42
        array $config = []
43
    ): ResponseInterface {
44
        return static::readRelay(
45
            $url,
46
            $connection,
47
            $cache,
48
            $logger,
49
            $config
50
        )();
51
    }
52
53
    /**
54
     * @param ConnectionInterface|null $connection
55
     * @param CacheInterface|null $cache
56
     * @param string $url
57
     * @param LoggerInterface|null $logger
58
     * @param array $config
59
     * @return callable
60
     */
61
    public static function readRelay(
62
        string $url,
63
        ConnectionInterface $connection = null,
64
        CacheInterface $cache = null,
65
        LoggerInterface $logger = null,
66
        array $config = []
67
    ): callable {
68
        $connection = $connection ?: Salesforce::getConnection();
69
70
        $builder = new RawBuilder(
71
            $connection,
72
            $connection,
73
            $cache ?: Salesforce::getCache(),
74
            $url,
75
            $logger ?: Salesforce::getLogger(),
76
            $config
77
        );
78
79
        return $builder->build();
80
    }
81
}
82