This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @param array | |
* @return bool | |
*/ | |
function isAssoc($array) | |
{ | |
if (!is_array($array)) { | |
return false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Force to redirect to https | |
* | |
* @return void | |
*/ | |
function forceHttps() | |
{ | |
// check already https |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function addXml($name, $input = null, $attrs = []) | |
{ | |
$xml = ""; | |
$xml .= "<{$name}"; | |
if (!empty($attrs)) { | |
foreach($attrs as $key => $value) { | |
$xml .= " {$key}=\"{$value}\""; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Util\Xml; | |
class Generator | |
{ | |
/** | |
* @param string $name | |
* @param string|array $inner (null) | |
* @param array $attrs (array) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
trait export | |
{ | |
public static function getHeader() | |
{ | |
$sCsv = ''; | |
foreach(get_class_vars(self::class) as $key => $value) { | |
$sCsv .= $key . ','; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// namespaces can be a pain in the ass, well NO LONGER! | |
function stripNamespaces($xml) | |
{ | |
return preg_replace([ | |
"/(\<(\w*|\-)*\:)/", // start node namespaces | |
"/(\<(\/{0,1})(\w*|\-)*\:)/", // end node namespaces | |
"/(\s\w*\:)/" // attribute namespaces | |
], [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Model | |
{ | |
public function __toString() { | |
return json_encode(get_object_vars($this)); | |
} | |
} | |
$model = new Model(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function isAssoc(array $arr) | |
{ | |
if (array() === $arr) return false; | |
return array_keys($arr) !== range(0, count($arr) - 1); | |
} | |
function toXml($name, $a) { | |
$sReturn = "<$name>"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyService implements ServiceInterface | |
{ | |
public function boot() { | |
echo "booting..\n"; | |
} | |
public function run() { | |
echo "running...\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class X { | |
public function get(array $arr) { | |
return $arr; | |
} | |
} | |
$reflect = new ReflectionMethod('X', 'get'); | |
// first param for sake of example |