PrimitiveTernary.class.php

Go to the documentation of this file.
00001 <?php
00002 /****************************************************************************
00003  *   Copyright (C) 2006-2007 by Dmitry E. Demidov                           *
00004  *                                                                          *
00005  *   This program is free software; you can redistribute it and/or modify   *
00006  *   it under the terms of the GNU Lesser General Public License as         *
00007  *   published by the Free Software Foundation; either version 3 of the     *
00008  *   License, or (at your option) any later version.                        *
00009  *                                                                          *
00010  ****************************************************************************/
00011 /* $Id: PrimitiveTernary.class.php 4687 2007-12-09 18:57:18Z voxus $ */
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 ?>

Generated on Sun Dec 9 21:56:23 2007 for onPHP by  doxygen 1.5.4