Completed
Pull Request — master (#50)
by Juan Francisco
03:38
created

HeadersTrait::setRequestHeader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 6
rs 9.4286
cc 1
eloc 4
nc 1
nop 2
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