| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
* This file is part of Raven. |
| 5 |
* |
| 6 |
* (c) Sentry Team |
| 7 |
* |
| 8 |
* For the full copyright and license information, please view the LICENSE |
| 9 |
* file that was distributed with this source code. |
| 10 |
*/ |
| 11 |
|
| 12 |
/** |
| 13 |
* Utilities |
| 14 |
* |
| 15 |
* @package raven |
| 16 |
*/ |
| 17 |
|
| 18 |
class Raven_Util |
| 19 |
{ |
| 20 |
/** |
| 21 |
* Because we love Python, this works much like dict.get() in Python. |
| 22 |
* |
| 23 |
* Returns $var from $array if set, otherwise returns $default. |
| 24 |
* |
| 25 |
* @param array $array |
| 26 |
* @param string $var |
| 27 |
* @param mixed $default |
| 28 |
* @return mixed |
| 29 |
*/ |
| 30 |
public static function get($array, $var, $default = null) |
| 31 |
{ |
| 32 |
if (isset($array[$var])) { |
| 33 |
return $array[$var]; |
| 34 |
} |
| 35 |
|
| 36 |
return $default; |
| 37 |
} |
| 38 |
} |
| 39 |
|