PostfixUnaryExpression.class.php

Go to the documentation of this file.
00001 <?php
00002 /****************************************************************************
00003  *   Copyright (C) 2004-2007 by Konstantin V. Arkhipov, Anton E. Lebedevich *
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: PostfixUnaryExpression.class.php 4687 2007-12-09 18:57:18Z voxus $ */
00012 
00016     final class PostfixUnaryExpression implements LogicalObject, MappableObject
00017     {
00018         const IS_NULL           = 'IS NULL';
00019         const IS_NOT_NULL       = 'IS NOT NULL';
00020 
00021         const IS_TRUE           = 'IS TRUE';
00022         const IS_FALSE          = 'IS FALSE';
00023 
00024         private $subject    = null;
00025         private $logic      = null;
00026         
00027         public function __construct($subject, $logic)
00028         {
00029             $this->subject  = $subject;
00030             $this->logic    = $logic;
00031         }
00032         
00033         public function toDialectString(Dialect $dialect)
00034         {
00035             return
00036                 '('
00037                 .$dialect->toFieldString($this->subject)
00038                 .' '.$this->logic
00039                 .')';
00040         }
00041         
00045         public function toMapped(StorableDAO $dao, JoinCapableQuery $query)
00046         {
00047             return new self(
00048                 $dao->guessAtom($this->subject, $query),
00049                 $this->logic
00050             );
00051         }
00052         
00053         public function toBoolean(Form $form)
00054         {
00055             $subject = $form->toFormValue($this->subject);
00056                 
00057             switch ($this->logic) {
00058                 case self::IS_NULL:
00059                     return null === $subject;
00060 
00061                 case self::IS_NOT_NULL:
00062                     return null !== $subject;
00063 
00064                 case self::IS_TRUE:
00065                     return true === $subject;
00066 
00067                 case self::IS_FALSE:
00068                     return false === $subject;
00069 
00070                 default:
00071                     
00072                     throw new UnsupportedMethodException(
00073                         "'{$this->logic}' doesn't supported yet"
00074                     );
00075             }
00076         }
00077     }
00078 ?>

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