Login   Register  
PHP Classes
elePHPant
Icontem

File: src/eMacros/Runtime/Logical/LogicalOr.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Emmanuel Antico  >  eMacros  >  src/eMacros/Runtime/Logical/LogicalOr.php  >  Download  
File: src/eMacros/Runtime/Logical/LogicalOr.php
Role: Class source
Content type: text/plain
Description: Class source
Class: eMacros
PHP LISP language interpreter
Author: By
Last change:
Date: 2014-01-13 05:23
Size: 686 bytes
 

Contents

Class file image Download
<?php
namespace eMacros\Runtime\Logical;

use 
eMacros\Applicable;
use 
eMacros\Scope;
use 
eMacros\GenericList;

class 
LogicalOr implements Applicable {
    
/**
     * Applies a logical OR to all operands
     * Usage: (or true true) (or false false false)
     * Returns: boolean
     * (non-PHPdoc)
     * @see \eMacros\Applicable::apply()
     */
    
public function apply(Scope $scopeGenericList $operands) {
        if (
count($operands) == 0) {
            throw new \
BadFunctionCallException("And: No parameters found.");
        }
        
        foreach (
$operands as $form) {
            if (
$value $form->evaluate($scope)) {
                return 
$value;
            }
        }

        return 
$value;
    }
}