Completed
Push — master ( d0b903...a6beda )
by David
09:47
created

NoCandidateFoundException   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

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