Initial commit
This commit is contained in:
53
vendor/houdini/classes/components.php
vendored
Normal file
53
vendor/houdini/classes/components.php
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* classes/components.php
|
||||
*
|
||||
* This class is for managing template components.
|
||||
*
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com/Houdini
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Houdini\Classes;
|
||||
|
||||
class Components {
|
||||
public static $components = [];
|
||||
|
||||
public static function parse( $data ) {
|
||||
foreach ( self::$components as $key => $replace ) {
|
||||
$find = "~{($key)}~i";
|
||||
$data = preg_replace( $find, $replace, $data );
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a $key->$value combination to the $components array.
|
||||
*
|
||||
* @param {string} [$key]
|
||||
* @param {wild} [$value]
|
||||
* @return {bool}
|
||||
*/
|
||||
public static function set( $name, $value = '' ) {
|
||||
if ( null == $value ) {
|
||||
$value = '';
|
||||
}
|
||||
self::$components[ $name ] = $value;
|
||||
return true;
|
||||
}
|
||||
public static function unset( $name ) {
|
||||
if ( isset( self::$components[ $name ] ) ) {
|
||||
unset( self::$components[ $name ] );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static function append( $name, $value ) {
|
||||
if ( ! isset( self::$components[ $name ] ) ) {
|
||||
return self::set( $name, $value );
|
||||
}
|
||||
$curr = self::$components[ $name ];
|
||||
self::$components[ $name ] = $curr . $value;
|
||||
return true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user