File: src/eMacros/Runtime/Collection/Count.php

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

Contents

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

use
eMacros\Runtime\GenericFunction;

class
Count extends GenericFunction {
   
/**
     * Counts the elements on an array
     * Usage: (Array::count (array 1 2 3 4 5))
     * Returns: int
     * (non-PHPdoc)
     * @see \eMacros\Runtime\GenericFunction::execute()
     */
   
public function execute(array $arguments) {
        if (empty(
$arguments)) {
            throw new \
InvalidArgumentException("Count: No parameters found.");
        }
       
        list(
$list) = $arguments;
   
        return
is_string($list) ? strlen($list) : count($list);
    }
}
?>

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