Completed
Push — master ( 782892...5bf53f )
by Juan Francisco
03:56
created

HeadersTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 1
cbo 0
dl 0
loc 32
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getResponseHeaders() 0 3 1
A getStatusCode() 0 3 1
A setRequestHeader() 0 6 1
1
<?php
2
3
namespace Zumba\Mink\Driver;
4
5
/**
6
 * Class HeadersTrait
7
 * @package Zumba\Mink\Driver
8
 */
9
trait HeadersTrait {
10
11
  /**
12
   * Gets the current request response headers
13
   * Should be called only after a request, other calls are undefined behaviour
14
   * @return array
15
   */
16
  public function getResponseHeaders() {
17
    return $this->browser->responseHeaders();
0 ignored issues
show
Bug introduced by
The property browser does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
18
  }
19
20
  /**
21
   * Current request status code response
22
   * @return int
23
   */
24
  public function getStatusCode() {
25
    return $this->browser->getStatusCode();
26
  }
27
28
  /**
29
   * The name say its all
30
   * @param string $name
31
   * @param string $value
32
   */
33
  public function setRequestHeader($name, $value) {
34
    $header = array();
35
    $header[$name] = $value;
36
    //TODO: as a limitation of the driver it self, we will send permanent for the moment
37
    $this->browser->addHeader($header, true);
38
  }
39
40
}
41