Openemr fhir search (#4349)
[openemr.git] / src / Services / Search / SearchQueryFragment.php
blob77c6822f2578a7556a8781e36348bbba93bcfd27
1 <?php
3 /**
4 * SearchQueryFragment represents the a fragment of a SQL where clause that contains both the SQL statement and the
5 * parameterized bound values that will be used in the SQL statement.
6 * @package openemr
7 * @link http://www.open-emr.org
8 * @author Stephen Nielson <stephen@nielson.org>
9 * @copyright Copyright (c) 2021 Stephen Nielson <stephen@nielson.org>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 namespace OpenEMR\Services\Search;
15 class SearchQueryFragment
17 /**
18 * @var string
20 private $fragment;
22 /**
23 * @var mixed[]
25 private $boundValues;
28 public function __construct($fragment = "", $boundValues = null)
30 $this->setFragment($fragment);
31 $this->boundValues = is_array($boundValues) ? $boundValues : [];
34 /**
35 * @return mixed[]
37 public function getBoundValues(): array
39 return $this->boundValues;
42 /**
43 * @param mixed $boundValue
45 public function addBoundValue($boundValue): void
47 $this->boundValues[] = $boundValue;
50 /**
51 * @return string
53 public function getFragment(): string
55 return $this->fragment;
58 /**
59 * @param string $fragment
61 public function setFragment(string $fragment): void
63 $this->fragment = $fragment;
66 public function setQueryFragment(string $fragment, $boundValue)
68 $this->setFragment($fragment);
69 $this->addBoundValue($boundValue);
72 /**
73 * Helper statement useful for debugging the query fragment.
74 * @return string
76 public function __toString()
78 return "(fragment=" . $this->getFragment() . ", boundValues=[" . implode(",", $this->boundValues) . "])";