PHP Classes

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

Recommend this page to a friend!
  Classes of Emmanuel Antico   eMacros   src/eMacros/Runtime/Logical/LogicalAnd.php   Download  
File: src/eMacros/Runtime/Logical/LogicalAnd.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: 689 bytes
 

Contents

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

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

class
LogicalAnd implements Applicable {
   
/**
     * Applies a logical AND to all operands
     * Usage: (and true true) (and true true 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 $expr) {
            if (!
$value = $expr->evaluate($scope)) {
                return
$value;
            }
        }

        return
$value;
    }
}