Skip to content

Instantly share code, notes, and snippets.

@khoand0000
Created November 29, 2015 12:22
Show Gist options
  • Save khoand0000/326082a1e516edb4d412 to your computer and use it in GitHub Desktop.
Save khoand0000/326082a1e516edb4d412 to your computer and use it in GitHub Desktop.
My shared class #array
<?php
/**
* Created by PhpStorm.
* User: khoand
* Date: 11/29/15
* Time: 7:14 PM
*/
class Shared
{
public static function key($array, $key, $default = null)
{
return isset($array[$key]) ? $array[$key] : $default;
}
public static function attribute($object, $key, $default = null)
{
return isset($object->$key) ? $object->$key : $default;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment