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