This repository has been archived by the owner on Jan 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Result.php
92 lines (80 loc) · 2.11 KB
/
Result.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/**
* Result class file
*
* @package EndyJasmi\Neo4j\Response
*/
namespace EndyJasmi\Neo4j\Response;
use EndyJasmi\Neo4j\ConnectionInterface;
use EndyJasmi\Neo4j\FactoryInterface;
use EndyJasmi\Neo4j\Request\StatementInterface;
use Illuminate\Support\Collection;
/**
* Result is a concrete implementation of result interface
*/
class Result extends Collection implements ResultInterface
{
/**
* @var ConnectionInterface Connection instance
*/
protected $connection;
/**
* @var FactoryInterface Factory instance
*/
protected $factory;
/**
* @var StatementInterface Statement instance
*/
protected $statement;
/**
* @var array Status array
*/
protected $status = array();
/**
* Result constructor
*
* @param FactoryInterface $factory Factory instance
* @param ConnectionInterface $connection Connection instance
* @param StatementInterface $statement Statement instance
* @param array $result Result array
*/
public function __construct(
FactoryInterface $factory,
ConnectionInterface $connection,
StatementInterface $statement,
array $result
) {
$this->factory = $factory;
$this->connection = $connection;
$this->statement = $statement;
foreach ($result['data'] as $data) {
$row = array_combine($result['columns'], $data['row']);
$this->push($row);
}
$this->statement->setResult($this);
$this->status = $result['stats'];
$this->connection->fire(
$this->statement->getQuery(),
$this->statement->getParameters(),
$this->statement->getTime()
);
}
/**
* Get statement instance
*
* @return StatementInterface Return statement instance
*/
public function getStatement()
{
return $this->statement;
}
/**
* Get status instance
*
* @return StatusInterface Return status instance
*/
public function getStatus()
{
return $this->factory->createStatus($this->status);
}
}