Assert   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A throwable() 0 13 4
1
<?php
2
3
namespace ZoiloMora\ElasticAPM\Utils;
4
5
/**
6
 * Provides assertion for backward compatibility
7
 */
8
final class Assert
9
{
10
    /**
11
     * @param mixed $exception
12
     *
13
     * @throws \InvalidArgumentException
14
     */
15
    public static function throwable($exception)
16
    {
17
        // PHP >= 7.0
18
        if (true === interface_exists('\Throwable') && is_subclass_of($exception, '\Throwable')) {
19
            return;
20
        }
21
22
        // PHP < 7.0
23
        if ($exception instanceof \Exception) {
24
            return;
25
        }
26
27
        throw new \InvalidArgumentException('An object of type \Throwable or \Exception is required.');
28
    }
29
}
30