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