DiscoveryFailedException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 40
ccs 10
cts 12
cp 0.8333
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getExceptions() 0 4 1
A create() 0 10 2
1
<?php
2
3
namespace Http\Discovery\Exception;
4
5
use Http\Discovery\Exception;
6
7
/**
8
 * Thrown when all discovery strategies fails to find a resource.
9
 *
10
 * @author Tobias Nyholm <[email protected]>
11
 */
12
final class DiscoveryFailedException extends \Exception implements Exception
13
{
14
    /**
15
     * @var \Exception[]
16
     */
17
    private $exceptions;
18
19
    /**
20
     * @param string       $message
21
     * @param \Exception[] $exceptions
22
     */
23 6
    public function __construct($message, array $exceptions = [])
24
    {
25 6
        $this->exceptions = $exceptions;
26
27 6
        parent::__construct($message);
28 6
    }
29
30
    /**
31
     * @param \Exception[] $exceptions
32
     */
33 6
    public static function create($exceptions)
34
    {
35 6
        $message = 'Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors';
36 6
        foreach ($exceptions as $e) {
37 6
            $message .= "\n - ".$e->getMessage();
38
        }
39 6
        $message .= "\n\n";
40
41 6
        return new self($message, $exceptions);
42
    }
43
44
    /**
45
     * @return \Exception[]
46
     */
47
    public function getExceptions()
48
    {
49
        return $this->exceptions;
50
    }
51
}
52