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

ErrorGenerator::mockException()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 13
nc 4
nop 1
dl 0
loc 17
rs 9.2
c 0
b 0
f 0
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