Subversion Repositories Applications.framework

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5 aurelien 1
<?php
2
/**
3
 * A class to represent elements that have a value => comment format.
4
 *
5
 * PHP version 5
6
 *
7
 * @category  PHP
8
 * @package   PHP_CodeSniffer
9
 * @author    Greg Sherwood <gsherwood@squiz.net>
10
 * @author    Marc McIntyre <mmcintyre@squiz.net>
11
 * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
12
 * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
13
 * @version   CVS: $Id: PairElement.php,v 1.9 2008/12/02 02:38:33 squiz Exp $
14
 * @link      http://pear.php.net/package/PHP_CodeSniffer
15
 */
16
 
17
if (class_exists('PHP_CodeSniffer_CommentParser_AbstractDocElement', true) === false) {
18
    $error = 'Class PHP_CodeSniffer_CommentParser_AbstractDocElement not found';
19
    throw new PHP_CodeSniffer_Exception($error);
20
}
21
 
22
/**
23
 * A class to represent elements that have a value => comment format.
24
 *
25
 * An example of a pair element tag is the \@throws as it has an exception type
26
 * and a comment on the circumstance of when the exception is thrown.
27
 *
28
 * @category  PHP
29
 * @package   PHP_CodeSniffer
30
 * @author    Greg Sherwood <gsherwood@squiz.net>
31
 * @author    Marc McIntyre <mmcintyre@squiz.net>
32
 * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
33
 * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
34
 * @version   Release: 1.2.0RC1
35
 * @link      http://pear.php.net/package/PHP_CodeSniffer
36
 */
37
class PHP_CodeSniffer_CommentParser_PairElement extends PHP_CodeSniffer_CommentParser_AbstractDocElement
38
{
39
 
40
    /**
41
     * The value of the tag.
42
     *
43
     * @var string
44
     */
45
    private $_value = '';
46
 
47
    /**
48
     * The comment of the tag.
49
     *
50
     * @var string
51
     */
52
    private $_comment = '';
53
 
54
    /**
55
     * The whitespace that exists before the value elem.
56
     *
57
     * @var string
58
     */
59
    private $_valueWhitespace = '';
60
 
61
    /**
62
     * The whitespace that exists before the comment elem.
63
     *
64
     * @var string
65
     */
66
    private $_commentWhitespace = '';
67
 
68
 
69
    /**
70
     * Constructs a PHP_CodeSniffer_CommentParser_PairElement doc tag.
71
     *
72
     * @param PHP_CodeSniffer_CommentParser_DocElement $previousElement The element
73
     *                                                                  before this
74
     *                                                                  one.
75
     * @param array                                    $tokens          The tokens
76
     *                                                                  that comprise
77
     *                                                                  this element.
78
     * @param string                                   $tag             The tag that
79
     *                                                                  this element
80
     *                                                                  represents.
81
     * @param PHP_CodeSniffer_File                     $phpcsFile       The file that
82
     *                                                                  this element
83
     *                                                                  is in.
84
     */
85
    public function __construct(
86
        $previousElement,
87
        $tokens,
88
        $tag,
89
        PHP_CodeSniffer_File $phpcsFile
90
    ) {
91
        parent::__construct($previousElement, $tokens, $tag, $phpcsFile);
92
 
93
    }//end __construct()
94
 
95
 
96
    /**
97
     * Returns the element names that this tag is comprised of, in the order
98
     * that they appear in the tag.
99
     *
100
     * @return array(string)
101
     * @see processSubElement()
102
     */
103
    protected function getSubElements()
104
    {
105
        return array(
106
                'value',
107
                'comment',
108
               );
109
 
110
    }//end getSubElements()
111
 
112
 
113
    /**
114
     * Processes the sub element with the specified name.
115
     *
116
     * @param string $name             The name of the sub element to process.
117
     * @param string $content          The content of this sub element.
118
     * @param string $whitespaceBefore The whitespace that exists before the
119
     *                                 sub element.
120
     *
121
     * @return void
122
     * @see getSubElements()
123
     */
124
    protected function processSubElement($name, $content, $whitespaceBefore)
125
    {
126
        $element           = '_'.$name;
127
        $whitespace        = $element.'Whitespace';
128
        $this->$element    = $content;
129
        $this->$whitespace = $whitespaceBefore;
130
 
131
    }//end processSubElement()
132
 
133
 
134
    /**
135
     * Returns the value of the tag.
136
     *
137
     * @return string
138
     */
139
    public function getValue()
140
    {
141
        return $this->_value;
142
 
143
    }//end getValue()
144
 
145
 
146
    /**
147
     * Returns the comment associated with the value of this tag.
148
     *
149
     * @return string
150
     */
151
    public function getComment()
152
    {
153
        return $this->_comment;
154
 
155
    }//end getComment()
156
 
157
 
158
    /**
159
     * Returns the witespace before the content of this tag.
160
     *
161
     * @return string
162
     */
163
    public function getWhitespaceBeforeValue()
164
    {
165
        return $this->_valueWhitespace;
166
 
167
    }//end getWhitespaceBeforeValue()
168
 
169
 
170
}//end class
171
 
172
?>