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

Recommend this page to a friend!
  Classes of Emmanuel Antico  >  eMacros  >  src/eMacros/Runtime/Logical/LogicalIf.php  >  Download  
File: src/eMacros/Runtime/Logical/LogicalIf.php
Role: Class source
Content type: text/plain
Description: Class source
Class: eMacros
PHP LISP language interpreter
Author: By
Last change:
Date: 7 years ago
Size: 668 bytes
 

Contents

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

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

class
LogicalIf implements Applicable {
   
/**
     * If control structure implementation
     * Usage: (if (== (%#) 0) "No parameters found" (. (%#) " parameters found"))
     * Returns: mixed
     * (non-PHPdoc)
     * @see \eMacros\Applicable::apply()
     */
   
public function apply(Scope $scope, GenericList $args) {
        if (
count($args) == 0) {
            throw new \
BadFunctionCallException("If: No parameters found.");
        }
       
       
$index = $args[0]->evaluate($scope) ? 1 : 2;
        return isset(
$args[$index]) ? $args[$index]->evaluate($scope) : null;
    }
}

For more information send a message to info at phpclasses dot org.