Location: PHPKode > scripts > Redstart Templating > Redstart-Templating-master/Redstart/Templating/Placeholder/ObjectPlaceholder.php
<?php

namespace Redstart\Templating\Placeholder;

/**
 * Object Place Holder 
 *
 * @package Redstart    
 * @subpackage Redstart_Templating_Placeholder
 *
 * @author Hyyan Abo Fakher
 * @since Redstart 1.0
 * @version 1.0
 */
class ObjectPlaceholder implements PlaceholderInterface {

    private $params;

    /**
     * Constrcut New Object Placeholder
     */
    public function __construct() {
        $this->clean();
    }

    /**
     * Get all params from the placeholder
     * @return array
     */
    public function all() {
        return (array) $this->params;
    }

    /**
     * Clean the placeholder
     */
    public function clean() {
        $this->params = new \stdClass();
    }

    /**
     * Get param from the place holder
     * @param string $name
     * @return mixed|false false if the param is not in the placeholder 
     */
    public function get($name) {
        if ($this->has($name)) {
            return $this->params->{$name};
        }
        return false;
    }

    /**
     * Check if the given param is in the placeholder
     * @param string $name
     * @return boolean
     */
    public function has($name) {
        return isset($this->params->{$name});
    }

    /**
     * Remove param 
     * @param string $name
     * @return mixed|false false on failure or removed item on success 
     */
    public function remove($name) {
        if (($item = $this->get($name))) {
            unset($this->params->{$name});
            return $item;
        }
        return false;
    }

    /**
     * Add new param to the place holder 
     * @param string $name
     * @param mixed $value
     */
    public function set($name, $value) {
        $this->params->{(string) $name} = $value;
    }

    /**
     * Get the number of all params in the placeholder
     * @return int
     */
    public function count() {
        return count($this->all());
    }

    /**
     * Serialize the place holder
     * @return serialized 
     */
    public function serialize() {
        return serialize($this->params);
    }

    /**
     * Unserialize the place holder
     * @param serialized $serialized 
     */
    public function unserialize($serialized) {
        $this->params = unserialize($serialized);
    }

}

Return current item: Redstart Templating