jablonka.czprosek.czf

freenet-router

Subversion Repositories:
[/] [trunk/] [freenet-router/] [var/] [www/] [freenet-router/] [Framework/] [Annotation.php] - Rev 2

Compare with Previous - Blame - Download


<?php

namespace Phem;

use Phem\Core\Collection;

/**
 * Description of Annotation
 *
 * @author kubapet
 */
class Annotation
{

    /** @return array */
    static function parse($docComment)
    {
        preg_match_all("/\\@(form|textbox|selectbox|datebox|checkbox|xmlelement|xmlattribute|xmlobject|xmlvalue)\\s*(?:\\((.*?)\\))?/is", $docComment, $matches, PREG_SET_ORDER);
        $result = new Collection();
        foreach ($matches as $match)
        {
            $annotation = new Annotation;
            $annotation->name = strtolower($match[1]);
            if (count($match) > 2)
                $annotation->params = preg_split("/\\s*\\,\\s*/", trim($match[2]), -1, PREG_SPLIT_NO_EMPTY);
            $result->put($annotation->name,$annotation);
        }
        return $result;
    }

    private $name;
    private $params;

    protected function __construct()
    {
        
    }

    function getName()
    {
        return $this->name;
    }

    function getParamCount()
    {
        return count($this->params);
    }

    function getParam($index)
    {
        return $this->params[$index];
    }

    public function getParams()
    {
        return $this->params;
    }

}

Powered by WebSVN 2.2.1