PrefixUnaryExpression.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: PrefixUnaryExpression.class.php 4687 2007-12-09 18:57:18Z voxus $ */
00012 
00016     final class PrefixUnaryExpression implements LogicalObject, MappableObject
00017     {
00018         const NOT   = 'NOT';
00019         const MINUS = '-';
00020 
00021         private $subject    = null;
00022         private $logic      = null;
00023         
00024         public function __construct($logic, $subject)
00025         {
00026             $this->subject  = $subject;
00027             $this->logic    = $logic;
00028         }
00029         
00030         public function toDialectString(Dialect $dialect)
00031         {
00032             return
00033                 '('
00034                 .$this->logic
00035                 .' '.$dialect->toFieldString($this->subject)
00036                 .')';
00037         }
00038         
00042         public function toMapped(StorableDAO $dao, JoinCapableQuery $query)
00043         {
00044             return new self(
00045                 $this->logic,
00046                 $dao->guessAtom($this->subject, $query)
00047             );
00048         }
00049         
00050         public function toBoolean(Form $form)
00051         {
00052             $subject = $form->toFormValue($this->subject);
00053                 
00054             switch ($this->logic) {
00055                 case self::NOT :
00056                     return false === $subject;
00057 
00058                 default:
00059                     
00060                     throw new UnsupportedMethodException(
00061                         "'{$this->logic}' doesn't supported yet"
00062                     );
00063             }
00064         }
00065     }
00066 ?>

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