|
| 1 | +<?php |
| 2 | +/*========================================================================= |
| 3 | + Midas Server |
| 4 | + Copyright Kitware SAS, 26 rue Louis Guérin, 69100 Villeurbanne, France. |
| 5 | + All rights reserved. |
| 6 | + For more information visit http://www.kitware.com/. |
| 7 | +
|
| 8 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | + you may not use this file except in compliance with the License. |
| 10 | + You may obtain a copy of the License at |
| 11 | +
|
| 12 | + http://www.apache.org/licenses/LICENSE-2.0.txt |
| 13 | +
|
| 14 | + Unless required by applicable law or agreed to in writing, software |
| 15 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | + See the License for the specific language governing permissions and |
| 18 | + limitations under the License. |
| 19 | +=========================================================================*/ |
| 20 | + |
| 21 | +/** |
| 22 | + * Param DAO for the tracker module. |
| 23 | + * |
| 24 | + * @method int getParamId() |
| 25 | + * @method void setParamId(int $paramId) |
| 26 | + * @method int getScalarId() |
| 27 | + * @method void setScalarId(int $scalarId) |
| 28 | + * @method int getParamName() |
| 29 | + * @method void setParamName(int $paramName) |
| 30 | + * @method int getParamType() |
| 31 | + * @method void setParamType(int $paramType) |
| 32 | + * @method int getTextValue() |
| 33 | + * @method void setTextValue(int $textValue) |
| 34 | + * @method int getNumericValue() |
| 35 | + * @method void setNumericValue(int $numericValue) |
| 36 | + */ |
| 37 | +class Tracker_ParamDao extends Tracker_AppDao |
| 38 | +{ |
| 39 | + /** @var string */ |
| 40 | + public $_model = 'Param'; |
| 41 | + |
| 42 | + /** @var string */ |
| 43 | + public $_module = 'tracker'; |
| 44 | + |
| 45 | + /** |
| 46 | + * Set the value of the param, which will be either stored as a numeric |
| 47 | + * value if the paramValue can be coerced to numeric or else a text value. |
| 48 | + * |
| 49 | + * @param string $paramValue value to be set for this param |
| 50 | + */ |
| 51 | + public function setParamValue($paramValue) |
| 52 | + { |
| 53 | + if (!empty($paramValue) && is_numeric($paramValue)) { |
| 54 | + $this->setParamType('numeric'); |
| 55 | + $this->setNumericValue(floatval($paramValue)); |
| 56 | + } else { |
| 57 | + $this->setParamType('text'); |
| 58 | + $this->setTextValue($paramValue); |
| 59 | + } |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * Get the value of the param, regardless of its type, returning either a |
| 64 | + * numeric or a string. |
| 65 | + * |
| 66 | + * @return mixed value of the param |
| 67 | + */ |
| 68 | + public function getParamValue() |
| 69 | + { |
| 70 | + if ($this->getParamType() === 'numeric') { |
| 71 | + return $this->getNumericValue(); |
| 72 | + } else { |
| 73 | + return $this->getTextValue(); |
| 74 | + } |
| 75 | + } |
| 76 | +} |
0 commit comments