DelegatingProvider::request()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
crap 2
1
<?php
2
3
namespace Bangpound\oEmbed\Provider;
4
5
use Psr\Http\Message\RequestInterface;
6
7
class DelegatingProvider implements ProviderInterface
8
{
9
    private $resolver;
10
11 16
    public function __construct(ProviderResolverInterface $resolver)
12
    {
13 16
        $this->resolver = $resolver;
14 16
    }
15
16
    /**
17
     * @param $url
18
     * @param array $params
19
     *
20
     * @return RequestInterface
21
     */
22 6
    public function request($url, array $params = array())
23
    {
24 6
        if (false === $provider = $this->resolver->resolve($url, $params)) {
25 2
            throw new \RuntimeException();
26
        }
27
28 4
        return $provider->request($url, $params);
29
    }
30
31
    /**
32
     * Returns whether this class supports the given url.
33
     *
34
     * @param string $url    A url
35
     * @param array  $params The resource type or null if unknown
36
     *
37
     * @return bool True if this class supports the given url, false otherwise
38
     */
39 10
    public function supports($url, array $params = array())
40
    {
41 10
        return false !== $this->resolver->resolve($url, $params);
42
    }
43
}
44