Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00015 final class PrimitiveTernary extends BasePrimitive
00016 {
00017 private $falseValue = 0;
00018 private $trueValue = 1;
00019
00023 public function setTrueValue($trueValue)
00024 {
00025 $this->trueValue = $trueValue;
00026
00027 return $this;
00028 }
00029
00033 public function setFalseValue($falseValue)
00034 {
00035 $this->falseValue = $falseValue;
00036
00037 return $this;
00038 }
00039
00040 public function import($scope)
00041 {
00042 if (isset($scope[$this->name])) {
00043 if ($this->trueValue == $scope[$this->name])
00044 $this->value = true;
00045 elseif ($this->falseValue == $scope[$this->name])
00046 $this->value = false;
00047 else
00048 return false;
00049 } else {
00050 $this->clean();
00051
00052 return null;
00053 }
00054
00055 $this->raw = $scope[$this->name];
00056
00057 return $this->imported = true;
00058 }
00059
00060 public function importValue($value)
00061 {
00062 Assert::isTernaryBase($value, 'only ternary based accepted');
00063
00064 $this->value = $value;
00065
00066 return $this->imported = true;
00067 }
00068 }
00069 ?>