Completed
Push — master ( f451ed...7bd00e )
by Marco
02:07
created

Method   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A assert() 0 10 3
1
<?php
2
3
namespace MJanssen\Assert;
4
5
use InvalidArgumentException;
6
7
class Method
8
{
9
    const ALLOWED_METHODS = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'purge', 'options', 'trace', 'connect'];
10
11
    public static function assert(array $methods)
12
    {
13
        $methods = array_map('strtolower', $methods);
14
15
        foreach ($methods as $method) {
16
            if (!in_array($method, self::ALLOWED_METHODS)) {
17
                throw new InvalidArgumentException('Method "' . $method . '" is not valid, only the following methods are allowed: ' . join(', ', self::ALLOWED_METHODS));
18
            }
19
        }
20
    }
21
}