Completed
Push — fix-2494 ( 3153ee...40d9bb )
by Sam
13:43 queued 06:38
created

ErrorGenerator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A mockException() 0 17 4
1
<?php
2
3
namespace SilverStripe\Logging\Tests\DetailedErrorFormatterTest;
4
5
use Exception;
6
use SilverStripe\Dev\TestOnly;
7
8
/**
9
 * WARNING: This file is sensitive to whitespace changes
10
 */
11
class ErrorGenerator implements TestOnly
12
{
13
    /**
14
     * Generate an exception with a trace depeth of at least 4
15
     *
16
     * @param int $depth
17
     * @return Exception
18
     * @throws Exception
19
     */
20
    public function mockException($depth = 0)
21
    {
22
        switch ($depth) {
23
            case 0:
24
                try {
25
                    $this->mockException(1);
26
                } catch (\Exception $ex) {
27
                    return $ex;
28
                }
29
                return null;
30
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
31
            case 4:
32
                throw new Exception('Error');
33
            default:
34
                return $this->mockException($depth + 1);
35
        }
36
    }
37
}
38