xref: /plugin/strata/aggregates/min.php (revision 5153720fcc1dd2b6e63035d45f7c2bc32e429371)
1*5153720fSfkaag71<?php
2*5153720fSfkaag71/**
3*5153720fSfkaag71 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
4*5153720fSfkaag71 * @author     Brend Wanders <b.wanders@utwente.nl>
5*5153720fSfkaag71 */
6*5153720fSfkaag71// must be run within Dokuwiki
7*5153720fSfkaag71if(!defined('DOKU_INC')) die('Meh.');
8*5153720fSfkaag71
9*5153720fSfkaag71/**
10*5153720fSfkaag71 * The minimum aggregator.
11*5153720fSfkaag71 */
12*5153720fSfkaag71class plugin_strata_aggregate_min extends plugin_strata_aggregate {
13*5153720fSfkaag71    function aggregate($values, $hint = null) {
14*5153720fSfkaag71        if($hint == 'strict') $values = array_filter($values, 'is_numeric');
15*5153720fSfkaag71        if(empty($values)) return array();
16*5153720fSfkaag71        return array(min($values));
17*5153720fSfkaag71    }
18*5153720fSfkaag71
19*5153720fSfkaag71    function getInfo() {
20*5153720fSfkaag71        return array(
21*5153720fSfkaag71            'desc'=>'Returns the minimum value. Any item that does not have a clear numeric value (i.e. starts with a number) is counted as 0. If the \'strict\' hint is used, values that are not strictly numeric (i.e. contains only a number) are ignored.',
22*5153720fSfkaag71            'hint'=>'\'strict\' to ignore non-numeric values',
23*5153720fSfkaag71            'tags'=>array('numeric')
24*5153720fSfkaag71        );
25*5153720fSfkaag71    }
26*5153720fSfkaag71}
27