Passed
Push — develop ( 2d5306...ec7ed8 )
by Anton
08:18
created

DockBlock   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 114
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 114
rs 10
c 0
b 0
f 0
wmc 6
1
<?php
2
/**
3
 * An complex example of how to write "dockblock", based on PEAR standard
4
 *
5
 * PEAR standard you can find at http://pear.php.net/manual/tr/standards.sample.php
6
 * PSR proposal you can find at https://github.com/phpDocumentor/fig-standards/tree/master/proposed
7
 *
8
 * Docblock comments start with "/**" at the top.  Notice how the "/"
9
 * lines up with the normal indenting and the asterisks on subsequent rows
10
 * are in line with the first asterisk. The last line of comment text
11
 * should be immediately followed on the next line by the closing asterisk
12
 * and slash and then the item you are commenting on should be on the next
13
 * line below that. Don't add extra lines. Please put a blank line
14
 * between paragraphs as well as between the end of the description and
15
 * the start of the tags. Wrap comments before 80 columns in order to
16
 * ease readability for a wide variety of users.
17
 *
18
 * Docblocks can only be used for programming constructs which allow them
19
 * (classes, properties, methods, defines, includes, globals). See the
20
 * phpDocumentor documentation for more information.
21
 * http://phpdoc.org/docs/latest/index.html
22
 *
23
 * The Javadoc Style Guide is an excellent resource for figuring out
24
 * how to say what needs to be said in docblock comments. Much of what is
25
 * written here is a summary of what is found there, though there are some
26
 * cases where what's said here overrides what is said there.
27
 * http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html
28
 *
29
 * The first line of any docblock is the summary. Make them one short
30
 * sentence, without a period at the end. Summaries for classes, properties
31
 * and constants should omit the subject and simply state the object,
32
 * because they are describing things rather than actions or behaviors.
33
 */
34
35
/**
36
 * Short description for file
37
 *
38
 * Usually this block is the same for all files in your project
39
 * It's should consists the following tags:
40
 *  - copyright string
41
 *  - license with link to full text
42
 *  - link to library repository or project homepage
43
 * All other information should be write in class dockblock
44
 *
45
 * Syntax and order of tags:
46
 * @.copyright [description]
47
 * @.license   [<url>] [name]
48
 * @.link      [URI] [<description>]
49
 *
50
 * @copyright Bluz PHP Team
51
 * @license   MIT
52
 * @link      https://github.com/bluzphp/framework
53
 */
54
55
declare(strict_types=1);
56
57
namespace Bluz;
58
59
/**
60
 * Short summary for class
61
 *
62
 * You should know the simple rule - one class in one file,
63
 * then all information about package, author, version, etc
64
 * you can write in dockblock of class
65
 *
66
 * Syntax and order of tags:
67
 * @.package    [level 1]\[level 2]\[etc.]
68
 * @.author     [name] [<email address>]
69
 * @.version    [<vector>] [<description>]
70
 * @.link       [URI] [<description>]
71
 * @.see        [URI | FQSEN] [<description>]
72
 * @.since      [version] [<description>]
73
 * @.deprecated [version] [<description>]
74
 *
75
 * Then you can describe magic methods and properties of class,
76
 * it's required for autosuggestion mechanism in IDE
77
 *
78
 * Syntax and order of magic properties and methods:
79
 * @.property   [Type] [name] [<description>]
80
 * @.method     [return type] [name]([[type] [parameter]<, ...>]) [<description>]
81
 *
82
 * @package     Bluz
83
 * @author      Anton Shevchuk <[email protected]>
84
 * @version     1.5.0 release version
85
 * @link        https://github.com/bluzphp/framework
86
 * @see         DockBlock, DockBlock::setFoo()
87
 * @since       1.0.0 first time this was introduced
88
 * @deprecated  2.0.0 no longer used by internal code and not recommended
89
 *
90
 * @property    integer $number
91
 * @method      integer getMagicNumber()
92
 */
93
class DockBlock
94
{
95
    /**
96
     * Short summary for property is optional, but recommended
97
     *
98
     * Syntax and order of tags:
99
     * @.var  ["Type"] [$element_name] [<description>]
100
     * @.link [URI] [<description>]
101
     * @.see  [URI | FQSEN] [<description>]
102
     *
103
     * @var  string contain a description
104
     * @link https://github.com/bluzphp/framework
105
     * @see  DockBlock
106
     */
107
    protected $foo = 'bar';
108
109
    /**
110
     * @var string simple property description
111
     */
112
    protected $bar;
113
114
    /**
115
     * Registers the status of foo's universe
116
     *
117
     * Summaries for methods should use 3rd person declarative rather
118
     * than 2nd person imperative, beginning with a verb phrase.
119
     *
120
     * Summaries should add description beyond the method's name. The
121
     * best method names are "self-documenting", meaning they tell you
122
     * basically what the method does.  If the summary merely repeats
123
     * the method name in sentence form, it is not providing more
124
     * information.
125
     *
126
     * Below are the tags commonly used for methods.  A `param` tag is
127
     * required for each parameter the method has.  The `return` tag are
128
     * mandatory.  The `throws` tag is required if the method uses exceptions.
129
     * The remainder should only be used when necessary.
130
     * Please use them in the order they appear here. phpDocumentor has
131
     * several other tags available, feel free to use them.
132
     *
133
     * The `param` tag contains the data type, then the parameter's
134
     * name, followed by a description.  By convention, the first noun in
135
     * the description is the data type of the parameter.  Articles like
136
     * "a", "an", and  "the" can precede the noun. The descriptions
137
     * should start with a phrase. If further description is necessary,
138
     * follow with sentences. Having two spaces between the name and the
139
     * description aids readability.
140
     *
141
     * When writing a phrase, do not capitalize and do not end with a period.
142
     * When writing a phrase followed by a sentence, do not capitalize the
143
     * phrase, but end it with a period to distinguish it from the start
144
     * of the next sentence
145
     *
146
     * Return tags should contain the data type then a description of
147
     * the data returned. The data type can be any of PHP's data types
148
     * (int, float, bool, string, array, object, resource, mixed)
149
     * and should contain the type primarily returned. For example, if
150
     * a method returns an object when things work correctly but false
151
     * when an error happens, say 'object' rather than 'mixed'.
152
     * Use 'void' if nothing is returned.
153
     *
154
     * Here's an example of how to format examples:
155
     * <code>
156
     * try {
157
     *     $dockBlock = new DockBlock();
158
     *     $dockBlock->setFoo('Bar');
159
     * } catch (\Exception $e) {
160
     *     echo $e->getMessage();
161
     * }
162
     * </code>
163
     *
164
     * Syntax and order of tags:
165
     * @.param      [Type] [name] [<description>]
166
     * @.return     [Type] [<description>]
167
     * @.throws     [Type] [<description>]
168
     *
169
     * @.see        [URI | FQSEN] [<description>]
170
     * @.since      [version] [<description>]
171
     * @.deprecated [version] [<description>]
172
     *
173
     * @param  string $arg1 the string to quote
174
     * @param  int    $arg2 an integer of how many problems happened.
175
     *                      Indent to the description's starting point
176
     *                      for long ones.
177
     *
178
     * @return int the integer of the set mode used. FALSE if foo
179
     *             foo could not be set.
180
     *
181
     * @throws \Exception if first argument is not a string
182
     *
183
     * @see        DockBlock::$foo, DockBlock::setFoo()
184
     * @since      1.3.0 Added the $arg2
185
     * @since      1.2.0
186
     * @deprecated 2.0.0
187
     */
188
    public function setFoo($arg1, $arg2 = 0)
189
    {
190
        /*
191
         * This is a "Block Comment." The format is the same as
192
         * Docblock Comments except there is only one asterisk at the
193
         * top. phpDocumentor doesn't parse these.
194
         */
195
        if (is_int($arg1)) {
196
            throw new \Exception("First argument should be string");
197
        }
198
199
        if ($arg1 == 'good' || $arg1 == 'fair') {
200
            $this->foo = $arg1;
201
            return 1;
202
        } elseif ($arg1 == 'poor' && $arg2 > 1) {
203
            $this->foo = 'poor';
204
            return 2;
205
        } else {
206
            return false;
207
        }
208
    }
209
}
210