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 | |
// 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 | |
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 | |
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 | |
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 | |
/** | |
* 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 | |
/** | |
* @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 | |
/** | |
* @param string|array | |
* @param string|array | |
* @param string | |
*/ | |
function implodeAssoc($glue, $arr, $key = null) | |
{ | |
if (is_array($l)) { |
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 NonStaticTest | |
{ | |
public function execute() | |
{ | |
array_fill(0, 100, 'a'); | |
} | |
} |
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 CustomFunctionality | |
{ | |
protected $functions = []; | |
public function addMethod(string $name, callable $function) | |
{ | |
$this->functions[$name] = $function; | |
return $this; |