Login   Register  
PHP Classes
elePHPant
Icontem

File: src/eMacros/Runtime/Logical/LogicalIf.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/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: 2014-01-13 05:23
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 $scopeGenericList $args) {
        if (
count($args) == 0) {
            throw new \
BadFunctionCallException("If: No parameters found.");
        }
        
        
$index $args[0]->evaluate($scope) ? 2;
        return isset(
$args[$index]) ? $args[$index]->evaluate($scope) : null;
    }
}