| 
<?php
 /*
 * Copyright (C) 2014 Everton
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 /**
 * This file is a simple example of use Ptk\utils\Validator for testing an validate directores.
 */
 
 function show_validation($directory, $rules){
 global $onerror;
 if(\Ptk\utils\Validator::directory($directory, $rules, true)){
 echo "This directory $directory is VALID.".PHP_EOL;
 }else{
 echo "This directory $directory is INVALID.".PHP_EOL;
 echo "Invalid for: ".PHP_EOL;
 
 echo join(', ', $onerror);
 }
 }
 
 try{
 require 'examples.inc.php';
 
 //testing files
 $directory = realpath('./');
 $rules = array(
 'read' => true//Checks whether the directory can be read.
 ,'write' => true//Checks whether the directory  can be write.
 ,'empty' => false//Check if directory is empty.
 );
 show_validation($directory, $rules);
 
 } catch (Exception $ex) {
 echo $ex->getMessage();
 exit($ex->getCode());
 }
 |