<?php
class Stuff
{
/*
Important comment
*/
public static function countObjTypes( array $data, array $types )
{
# $return['Other'] = 0;
foreach ( ( array ) $data as $obj ) {
$set = false;
array_walk( $types, function( $type ) use ( $obj, &$return, &$set )
{
if ( is_a( $obj, $type ) ) {
$return[$type]++;
$set = true;
}
} );
}
return $return;
}
}
// An example of how to use it
$form = new Form( 'Form', 'post' );
$honeyPot1 = new HoneyPotField( time() );
$honeyPot1->validator( new Validator( new HoneyPotTimeRule( 'This form was filled in too quickly, assumed bot, please allow 2 seconds to fill in the form' ) ) );
$honeyPot2 = new HoneyPotField();
$honeyPot2->validator( new Validator( new EqualRule( 'This field was unexpectedly filled in, assumed bot', '' ) ) );
if( $form->isSubmitted() )
$form->validate( );
echo $form->render( ); // outputs the form + elements