<?php
/**
 * YANA library
 *
 * @package yana
 * @licence http://creativecommons.org/licenses/by-nc-sa/2.5/
 */

/**
 * handle php files
 *
 * @access      public
 * @package     yana
 * @subpackage  io
 */
class Executeable extends InputStream
{

    /**
    * require / include a php file
    *
    * Tries to interpret the given file as php code using "require_once()"
    *
    * This implements dynamic loading of php source code.
    *
    * @uses $executeable->read()
    *
    * @access public
    * @return boolean
    */
    function read()
    {
        if ($this->exists()) {
            require_once($this->getFilename());
            return true;
        } else {
            return false;
        }
    }

    /**
    * alias of toString
    *
    * @ignore
    */
    function get()
    {
        return $this->toString();
    }

    /**
    * get the filename
    *
    * @uses $executeable->toString()
    *
    * @access public
    * @return String
    *
    * @ignore
    */
    function toString()
    {
        if (!$this->exists()) {
            return "PHP-File ".$this->getFilename()." does not exist\n";
        } else if ($this->isEmpty()) {
            return "PHP-File ".$this->getFilename()." is wether empty or not loaded\n";
        } else {
            return "PHP-File \"".$this->getFilename()."\"\n";
        }
    }

}

?>