-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionArguments.php
More file actions
43 lines (40 loc) · 1.06 KB
/
FunctionArguments.php
File metadata and controls
43 lines (40 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* Arikaim
*
* @link http://www.arikaim.com
* @copyright Copyright (c) Konstantin Atanasov <info@arikaim.com>
* @license http://www.arikaim.com/license
*
*/
namespace Arikaim\Core\Utils;
/**
* Function arguments helper
*/
class FunctionArguments
{
const BOOLEAN_TYPE = 'boolean';
const INTEGER_TYPE = 'integer';
const DOUBLE_TYPE = 'double';
const STRING_TYPE = 'string';
const ARRAY_TYPE = 'array';
const OBJECT_TYPE = 'object';
const NULL_TYPE = 'NULL';
const UNKNOWN_TYPE = 'unknown type';
/**
* Get funciton argument
*
* @param array $args
* @param integer $index
* @param mixed $type
* @return mixed|null
*/
public static function getArgument(array $args, int $index, $type = null)
{
if (isset($args[$index]) == false) {
return null;
}
$variableType = \gettype($args[$index]);
return ($type != null && $variableType != $type) ? null : $args[$index];
}
}