Regex::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 2
crap 1
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