EnhancedTestCase   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 10
dl 0
loc 16
rs 10
c 2
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A catchExpectedException() 0 14 2
1
<?php
2
3
namespace LE_ACME2Tests;
4
5
use PHPUnit;
6
7
class EnhancedTestCase extends PHPUnit\Framework\TestCase {
8
9
    protected function catchExpectedException(string $exception, \Closure $callback) : \Exception {
10
11
        try {
12
            $callback();
13
        } catch (\Exception $e) {
14
            $this->assertEquals(
15
                $exception,
16
                get_class($e),
17
                'Exception message: ' . $e->getMessage(),
18
            );
19
            return $e;
20
        }
21
22
        throw new \RuntimeException('Expected exception not thrown: ' . $exception);
23
    }
24
}