DelegatingProvider::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
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