Completed
Push — 1.0 ( 5a6c04...f17e34 )
by Valentin
05:45 queued 02:26
created

Transaction   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 78.56%

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 6
c 3
b 0
f 2
lcom 1
cbo 1
dl 0
loc 61
ccs 11
cts 14
cp 0.7856
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getHeaders() 0 4 1
A getHeader() 0 4 2
A setHeaders() 0 4 1
A setHeader() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of Transfer.
5
 *
6
 * For the full copyright and license information, please view the LICENSE file located
7
 * in the root directory.
8
 */
9
10
namespace Transfer\Adapter\Transaction;
11
12
/**
13
 * Common transaction model for requests and responses.
14
 */
15
abstract class Transaction extends DataAggregate
16
{
17
    /**
18
     * @var array Header collection
19
     */
20
    protected $headers;
21
22
    /**
23
     * @param array|\Iterator|\Traversable $data    Data collection
24
     * @param array                        $headers Header collection
25
     */
26 24
    public function __construct($data = array(), $headers = array())
27
    {
28 24
        parent::__construct($data);
29
30 24
        $this->headers = $headers;
31 24
    }
32
33
    /**
34
     * Gets header collection.
35
     *
36
     * @return array Header collection
37
     */
38 3
    public function getHeaders()
39
    {
40 3
        return $this->headers;
41
    }
42
43
    /**
44
     * Gets header by key.
45
     *
46
     * @param string $key
47
     *
48
     * @return mixed
49
     */
50 1
    public function getHeader($key)
51
    {
52 1
        return array_key_exists($key, $this->headers) ? $this->headers[$key] : null;
53
    }
54
55
    /**
56
     * Sets a header collection.
57
     *
58
     * @param array $headers Header collection
59
     */
60 1
    public function setHeaders($headers)
61
    {
62 1
        $this->headers = $headers;
63 1
    }
64
65
    /**
66
     * Sets a header.
67
     *
68
     * @param string $key   Key
69
     * @param mixed  $value Value
70
     */
71
    public function setHeader($key, $value)
72
    {
73
        $this->headers[$key] = $value;
74
    }
75
}
76