Skip to content

Commit f17a668

Browse files
committed
Provide methods to retrieve the query parameters that have been set.
1 parent 9073901 commit f17a668

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

src/Query.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,25 @@ public function setParameter($name, $value)
7070
return $this;
7171
}
7272

73+
/**
74+
* {@inheritdoc}
75+
*/
76+
public function getParameters()
77+
{
78+
return $this->parameters;
79+
}
80+
81+
/**
82+
* {@inheritdoc}
83+
*/
84+
public function getParameter($name)
85+
{
86+
if (!array_key_exists($name, $this->parameters)) {
87+
throw new \InvalidArgumentException("Parameter '$name' is not set.");
88+
}
89+
return $this->parameters[$name];
90+
}
91+
7392
/**
7493
* Prepares the query for execution.
7594
*/

src/QueryInterface.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,28 @@ public function setParameters(array $parameters);
3232
*/
3333
public function setParameter($name, $value);
3434

35+
/**
36+
* Returns the query parameters that have been set.
37+
*
38+
* @return array
39+
* An associative array of query parameters, keyed by parameter name.
40+
*/
41+
public function getParameters();
42+
43+
/**
44+
* Returns the query parameters with the given name.
45+
*
46+
* @param string $name
47+
* The name of the parameter.
48+
*
49+
* @return mixed
50+
* The value of the parameter.
51+
*
52+
* @throws \InvalidArgumentException
53+
* Thrown when the query parameter with the given name is not set.
54+
*/
55+
public function getParameter($name);
56+
3557
/**
3658
* Executes the query.
3759
*

0 commit comments

Comments
 (0)