DelegatingProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 37
ccs 9
cts 9
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A request() 0 8 2
A supports() 0 4 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