Completed
Push — master ( b8acd8...13d185 )
by Maciej
14:05
created

Transaction::getClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Created by Maciej Paprocki for Bureau-VA.
4
 * Date: 17/02/2016
5
 * Project Name: MaciekPaprocki\WordpressGuzzle
6
 * Time: 12:14
7
 */
8
9
namespace BureauVa\WordpressGuzzle\Transaction;
10
use GuzzleHttp\Promise\Promise;
11
12
/**
13
 * Class Transaction
14
 * @package MaciekPaprocki\WordpressGuzzle
15
 */
16
17
class Transaction
18
{
19
20
    public $promises = [];
21
    public $client = null;
22
23
    /**
24
     * Transaction constructor. You can pass clien
25
     * @param null $client
26
     */
27
    public function __construct($client = null)
28
    {
29
        $this->client = $client;
30
    }
31
32
    /**
33
     * @param $name
34
     * @param Promise $promise
35
     * @return $this
36
     */
37
    public function addPromise($name, Promise $promise)
38
    {
39
        $this->promises[$name] = $promise;
40
        return $this;
41
    }
42
43
    /**
44
     * Awaits all the promises and returns data
45
     * @return array
46
     */
47
    public function unwrap()
48
    {
49
50
        return  \GuzzleHttp\Promise\unwrap($this->promises);
51
    }
52
53
    /**
54
     * @return null
55
     */
56
    public function getClient()
57
    {
58
        return $this->client;
59
    }
60
61
    /**
62
     * @param $client
63
     */
64
    public function setClient($client)
65
    {
66
        $this->client = $client;
67
    }
68
69
    /**
70
     * @return array
71
     */
72
    public function getPromises()
73
    {
74
        return $this->promises;
75
    }
76
77
    /**
78
     * @param $promises
79
     */
80
    public function setPromises($promises)
81
    {
82
        $this->promises = $promises;
83
    }
84
}