PHPackages                             wirnex/arguments-check - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. wirnex/arguments-check

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

wirnex/arguments-check
======================

Data validating PHP

1.0.0(11y ago)0476MITPHPPHP &gt;=5.3.0

Since Feb 17Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Wirnex/arguments-check.php)[ Packagist](https://packagist.org/packages/wirnex/arguments-check)[ Docs](https://github.com/Wirnex)[ RSS](/packages/wirnex-arguments-check/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

arguments-check.php
===================

[](#arguments-checkphp)

Usage
-----

[](#usage)

Assume we have some function which takes an array as argument and then reads this array with some keys. In some situations the array may not contain specific keys. This class is to validate an input array passed into the function.

```
require 'ArgumentsCheck.php';

function feedMeWithAnArray(array $data)
{
	$balance = 0;
	// Using ArgumentsCheck class we describe what array we expect
	ArgumentsCheck::CheckArguments(array('userId', 'sum', 'timestamp'),  $data);
	//
	// here we sure that all arguments were passed to function
	// and we don't need any extra validation code
	$userId  = $data['userId'];
	$balance += $data['sum'];
	$time	 = $data['timestamp'];
}

// calling this function with not exactly what is wants
feedMeWithAnArray(array(
  'userId'=>130,
  'sum'=>1000,
  'timestam'=>'2014-06-29 13:44' // we have mistake here in key "timestam" while the function expects "timestamp"
                                 //
