PHP Classes

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

Recommend this page to a friend!
  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: 10 years ago
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 $scope, GenericList $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;
    }
}