Completed
Push — master ( 2c9994...2c71b8 )
by Tobias
21:21 queued 20:14
created

NoCandidateFoundException   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 92.31%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 24
ccs 12
cts 13
cp 0.9231
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 17 1
1
<?php
2
3
namespace Http\Discovery\Exception;
4
5
use Http\Discovery\Exception;
6
7
/**
8
 * When we have used a strategy but no candidates provided by that strategy could be used.
9
 *
10
 * @author Tobias Nyholm <[email protected]>
11
 */
12
final class NoCandidateFoundException extends \Exception implements Exception
13
{
14
    /**
15
     * @param string $strategy
16
     * @param array  $candidates
17
     */
18 7
    public function __construct($strategy, array $candidates)
19
    {
20 7
        $classes = array_map(
21 7
            function ($a) {
22
                return $a['class'];
23 7
            },
24
            $candidates
25 7
        );
26
27 7
        $message = sprintf(
28 7
            'No valid candidate found using strategy "%s". We tested the following candidates: %s.',
29 7
            $strategy,
30 7
            implode(', ', $classes)
31 7
        );
32
33 7
        parent::__construct($message);
34 7
    }
35
}
36