| @@ 43-51 (lines=9) @@ | ||
| 40 | return $this->matchContent($conditions, $sort, $offset, $limit); |
|
| 41 | } |
|
| 42 | ||
| 43 | public function matchOne(array $conditions, array $sort = array(), $offset = 0, $limit = 0) |
|
| 44 | { |
|
| 45 | $results = $this->match($conditions, $sort, $offset, $limit); |
|
| 46 | $count = count($results); |
|
| 47 | if ($count !== 1) { |
|
| 48 | throw new \Exception("Found $count " . $this->returns . " when expected exactly only one to match the conditions"); |
|
| 49 | } |
|
| 50 | return reset($results); |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @param array $conditions key: condition, value: int / string / int[] / string[] |
|
| @@ 65-73 (lines=9) @@ | ||
| 62 | * @return mixed |
|
| 63 | * @throws \Exception |
|
| 64 | */ |
|
| 65 | public function matchOne(array $contentConditions, array $versionConditions = array(), $sort = array(), $offset = 0) |
|
| 66 | { |
|
| 67 | $results = $this->match($contentConditions, $versionConditions, $sort, $offset, 2); |
|
| 68 | $count = count($results); |
|
| 69 | if ($count !== 1) { |
|
| 70 | throw new \Exception("Found $count " . $this->returns . " when expected exactly only one to match the conditions"); |
|
| 71 | } |
|
| 72 | return reset($results); |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * @param array $versionConditions |
|
| @@ 45-53 (lines=9) @@ | ||
| 42 | return $this->matchLocation($conditions, $sort, $offset, $limit); |
|
| 43 | } |
|
| 44 | ||
| 45 | public function matchOne(array $conditions, array $sort = array(), $offset = 0, $limit = 0) |
|
| 46 | { |
|
| 47 | $results = $this->match($conditions, $sort, $offset, $limit); |
|
| 48 | $count = count($results); |
|
| 49 | if ($count !== 1) { |
|
| 50 | throw new \Exception("Found $count " . $this->returns . " when expected exactly only one to match the conditions"); |
|
| 51 | } |
|
| 52 | return reset($results); |
|
| 53 | } |
|
| 54 | ||
| 55 | /** |
|
| 56 | * @param array $conditions key: condition, value: value: int / string / int[] / string[] |
|