Regex   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 38
wmc 4
lcom 1
cbo 0
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A dispatch() 0 8 3
1
<?php
2
namespace Skansing\Escapology\Dispatcher;
3
4
use \Skansing\Escapology\Dispatcher;
5
  
6
class Regex implements Dispatcher {
7
 
8
    /**
9
     * @var string $uri
10
     */
11
    private $uri;
12
    /**
13
     * @var string $verb
14
     */
15
    private $verb;
16
17
  /**
18
   * @param string $verb The HTTP request method/verb
19
   * @param string $uri  The HTTP URI
20
   */
21 10
  public function __construct(
22
    $verb,
23
    $uri
24
  ){
25 10
    $this->verb = $verb;
26 10
    $this->uri = $uri;
27 10
  }
28
29
  /**
30
   * Returns if the route was found or not
31
   * 
32
   * @param Array $routesData
33
   * @return int
34
   */
35 4
  public function dispatch($routesData)
36
  {
37 4
    if(empty($routesData)) {
38 2
      return self::NOT_FOUND;
39
    }
40
41 2
   return preg_match($routesData[$this->verb], $this->uri) ? self::FOUND : self::NOT_FOUND;
42
  }
43
}
44