PageRenderTime 60ms CodeModel.GetById 52ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/framework/vendor/zend/Zend/Reflection/Docblock/Tag/Param.php

http://zoop.googlecode.com/
PHP | 93 lines | 35 code | 11 blank | 47 comment | 5 complexity | 2ea05305f902062b0f2fc144c209ccb9 MD5 | raw file
 1<?php
 2/**
 3 * Zend Framework
 4 *
 5 * LICENSE
 6 *
 7 * This source file is subject to the new BSD license that is bundled
 8 * with this package in the file LICENSE.txt.
 9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
14 *
15 * @category   Zend
16 * @package    Zend_Reflection
17 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
18 * @license    http://framework.zend.com/license/new-bsd     New BSD License
19 * @version    $Id: Param.php 20096 2010-01-06 02:05:09Z bkarwin $
20 */
21
22/** Zend_Reflection_Docblock_Tag */
23require_once 'Zend/Reflection/Docblock/Tag.php';
24
25/**
26 * @category   Zend
27 * @package    Zend_Reflection
28 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
29 * @license    http://framework.zend.com/license/new-bsd     New BSD License
30 */
31class Zend_Reflection_Docblock_Tag_Param extends Zend_Reflection_Docblock_Tag
32{
33    /**
34     * @var string
35     */
36    protected $_type = null;
37
38    /**
39     * @var string
40     */
41    protected $_variableName = null;
42
43    /**
44     * Constructor
45     *
46     * @param string $tagDocblockLine
47     */
48    public function __construct($tagDocblockLine)
49    {
50        $matches = array();
51
52        if (!preg_match('#^@(\w+)\s+([\w|\\\]+)(?:\s+(\$\S+))?(?:\s+(.*))?#s', $tagDocblockLine, $matches)) {
53            require_once 'Zend/Reflection/Exception.php';
54            throw new Zend_Reflection_Exception('Provided docblock line is does not contain a valid tag');
55        }
56
57        if ($matches[1] != 'param') {
58            require_once 'Zend/Reflection/Exception.php';
59            throw new Zend_Reflection_Exception('Provided docblock line is does not contain a valid @param tag');
60        }
61
62        $this->_name = 'param';
63        $this->_type = $matches[2];
64
65        if (isset($matches[3])) {
66            $this->_variableName = $matches[3];
67        }
68
69        if (isset($matches[4])) {
70            $this->_description = preg_replace('#\s+#', ' ', $matches[4]);
71        }
72    }
73
74    /**
75     * Get parameter variable type
76     *
77     * @return string
78     */
79    public function getType()
80    {
81        return $this->_type;
82    }
83
84    /**
85     * Get parameter name
86     *
87     * @return string
88     */
89    public function getVariableName()
90    {
91        return $this->_variableName;
92    }
93}