Skip to content

Commit e0bf363

Browse files
committed
chore: Enhance PHP Docs
1 parent d8d09a7 commit e0bf363

5 files changed

Lines changed: 22 additions & 75 deletions

File tree

WebFiori/Json/CaseConverter.php

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,17 @@
1414
* A class which is used to convert string case from one to another (e.g. camel to snake).
1515
*
1616
* @author Ibrahim
17-
*
18-
* @version 1.0
1917
*/
2018
class CaseConverter {
2119
/**
22-
* An array of supported property styles.
20+
* An array of supported letter cases.
2321
*
2422
* This array holds the following values:
2523
* <ul>
26-
* <li>camel</li>
27-
* <li>kebab</li>
28-
* <li>snake</li>
29-
* <li>none</li>
24+
* <li>same</li>
25+
* <li>upper</li>
26+
* <li>lower</li>
3027
* </ul>
31-
*
3228
*/
3329
const LETTER_CASE = [
3430
'same',
@@ -45,7 +41,6 @@ class CaseConverter {
4541
* <li>snake</li>
4642
* <li>none</li>
4743
* </ul>
48-
*
4944
*/
5045
const PROP_NAME_STYLES = [
5146
'camel',
@@ -76,13 +71,11 @@ class CaseConverter {
7671
* </ul>
7772
* If the given value is none of the given 3, the string wouldn't be changed.
7873
*
79-
*
8074
* @return string The same string converted to selected style.
81-
*
8275
*/
8376
public static function convert(string $value, string $style, string $letterCase = 'same') : string {
8477
if ($style == 'snake') {
85-
return self::toSnackCase($value, $letterCase);
78+
return self::toSnakeCase($value, $letterCase);
8679
} else if ($style == 'kebab') {
8780
return self::toKebabCase($value, $letterCase);
8881
} else if ($style == 'camel') {
@@ -117,7 +110,6 @@ public static function isUpper(string $char) : bool {
117110
*
118111
* @return string The method will return the string after conversion. For
119112
* example, if the string is 'my-val', the method will return the string 'myVal'.
120-
*
121113
*/
122114
public static function toCamelCase(string $value, string $letterCase = 'same') : string {
123115
$retVal = '';
@@ -158,7 +150,6 @@ public static function toCamelCase(string $value, string $letterCase = 'same') :
158150
*
159151
* @return string The method will return the string after conversion. For
160152
* example, if the string is 'myVal', the method will return the string 'my-val'.
161-
*
162153
*/
163154
public static function toKebabCase(string $value, string $letterCase = 'same') : string {
164155
return self::toSnakeOrKebab($value, $letterCase, '_', '-');
@@ -179,9 +170,8 @@ public static function toKebabCase(string $value, string $letterCase = 'same') :
179170
*
180171
* @return string The method will return the string after conversion. For
181172
* example, if the string is 'my-val', the method will return the string 'my_val'.
182-
*
183173
*/
184-
public static function toSnackCase(string $value, string $letterCase = 'same') : string {
174+
public static function toSnakeCase(string $value, string $letterCase = 'same') : string {
185175
return self::toSnakeOrKebab($value, $letterCase, '-', '_');
186176
}
187177
private static function addChar($x, &$isNumFound, $to, $char, &$snakeOrKebabFound, $nextChar) : string {

WebFiori/Json/JsonConverter.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
* A class to convert Json instance to it's JSON string representation.
1515
*
1616
* @author Ibrahim
17-
*
18-
* @version 1.0
1917
*/
2018
class JsonConverter {
2119
private static $CRLF = "\r\n";

WebFiori/Json/JsonI.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,18 @@
1111
namespace WebFiori\Json;
1212

1313
/**
14-
* An interface for the objects that can be added to an instance of JsonX.
14+
* An interface for the objects that can be added to an instance of Json.
1515
* @author Ibrahim
16-
* @version 1.0
17-
* @see JsonX
16+
* @see Json
1817
*/
1918
interface JsonI {
2019
/**
21-
* Returns an object of type JsonX.
20+
* Returns an object of type Json.
2221
* This method can be implemented by any class that will be added
23-
* to any JsonX instance. It is used to customize the generated
22+
* to any Json instance. It is used to customize the generated
2423
* JSON string.
2524
*
26-
* @return Json An instance of JsonX.
27-
*
28-
* @since 1.0
25+
* @return Json An instance of Json.
2926
*/
3027
public function toJSON() : Json;
3128
}

WebFiori/Json/JsonTypes.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,50 +14,34 @@
1414
* A class that contains constants which represents supported JSON data types.
1515
*
1616
* @author Ibrahim
17-
*
18-
* @version 1.0
1917
*/
2018
abstract class JsonTypes {
2119
/**
2220
* A constant that indicates that given datatype is of type array.
23-
*
24-
* @since 1.0
2521
*/
2622
const ARR = 'array';
2723
/**
2824
* A constant that indicates that given datatype is of type boolean.
29-
*
30-
* @since 1.0
3125
*/
3226
const BOOL = 'boolean';
3327
/**
3428
* A constant that indicates that given datatype is of type double (or float).
35-
*
36-
* @since 1.0
3729
*/
3830
const DOUBLE = 'double';
3931
/**
4032
* A constant that indicates that given datatype is of type integer.
41-
*
42-
* @since 1.0
4333
*/
4434
const INT = 'integer';
4535
/**
4636
* A constant that indicates that given datatype is null.
47-
*
48-
* @since 1.0
4937
*/
5038
const NUL = 'NULL';
5139
/**
5240
* A constant that indicates that given datatype is an object.
53-
*
54-
* @since 1.0
5541
*/
5642
const OBJ = 'object';
5743
/**
5844
* A constant that indicates that given datatype is of type string.
59-
*
60-
* @since 1.0
6145
*/
6246
const STRING = 'string';
6347
}

WebFiori/Json/Property.php

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,39 @@
1818
*/
1919
class Property {
2020
/**
21+
* A boolean value that determines if an array will be represented as an object or not.
2122
*
2223
* @var boolean
23-
*
24-
* @since 1.0
2524
*/
2625
private $asObject;
2726
/**
27+
* The datatype of the property value.
2828
*
2929
* @var string
30-
*
31-
* @since 1.0
3230
*/
3331
private $datatype;
34-
private $lettersCase;
3532
/**
33+
* The case of the property name (same, upper, or lower).
3634
*
3735
* @var string
36+
*/
37+
private $lettersCase;
38+
/**
39+
* The name of the property.
3840
*
39-
* @since 1.0
41+
* @var string
4042
*/
4143
private $name;
4244
/**
45+
* The style of the property name (camel, kebab, snake, or none).
4346
*
4447
* @var string
45-
*
46-
* @since 1.0
4748
*/
4849
private $probsStyle;
4950
/**
51+
* The value of the property.
5052
*
5153
* @var mixed
52-
*
53-
* @since 1.0
5454
*/
5555
private $value;
5656
/**
@@ -80,8 +80,6 @@ class Property {
8080
* The default value is 'same'.
8181
*
8282
* @throws InvalidArgumentException If the name of the property is invalid
83-
*
84-
* @since 1.0
8583
*/
8684
public function __construct(string $name, $value, ?string $style = 'none', string $case = 'same') {
8785
$this->name = '';
@@ -104,8 +102,6 @@ public function __construct(string $name, $value, ?string $style = 'none', strin
104102
* Returns the value of the property.
105103
*
106104
* @return mixed|Json The value of the property.
107-
*
108-
* @since 1.0
109105
*/
110106
public function &getValue() {
111107
return $this->value;
@@ -130,8 +126,6 @@ public function getCase() : string {
130126
*
131127
* @return string The returned string will have the following syntax:
132128
* "json:&lt;type&gt;" where "&lt;type&gt;" is the datatype of the property.
133-
*
134-
* @since 1.0
135129
*/
136130
public function getJsonXTagName() : string {
137131
$type = $this->getType();
@@ -166,8 +160,6 @@ public function getJsonXTagName() : string {
166160
*
167161
* @return string The name of the property. Note that the returned value
168162
* will depend on the style at which the property name is set to use.
169-
*
170-
* @since 1.0
171163
*/
172164
public function getName() : string {
173165
return $this->name;
@@ -183,8 +175,6 @@ public function getName() : string {
183175
* <li>none</li>
184176
* </ul>
185177
* The default value is 'none'.
186-
*
187-
* @since 1.0
188178
*/
189179
public function getStyle() : string {
190180
return $this->probsStyle;
@@ -201,8 +191,6 @@ public function getStyle() : string {
201191
* <li>object</li>
202192
* <li>NULL</li>
203193
* </ul>
204-
*
205-
* @since 1.0
206194
*/
207195
public function getType() : string {
208196
return $this->datatype;
@@ -215,8 +203,6 @@ public function getType() : string {
215203
*
216204
* @return bool If the property will be represented as object, true is
217205
* returned. False otherwise.
218-
*
219-
* @since 1.0
220206
*/
221207
public function isAsObject() : bool {
222208
return $this->asObject;
@@ -230,8 +216,6 @@ public function isAsObject() : bool {
230216
*
231217
* @param bool $bool True to represent the array as object. False
232218
* otherwise.
233-
*
234-
* @since 1.0
235219
*/
236220
public function setAsObject(bool $bool) {
237221
$this->asObject = $bool;
@@ -243,8 +227,6 @@ public function setAsObject(bool $bool) {
243227
*
244228
* @return bool If the name is set, the method will return true. False
245229
* otherwise.
246-
*
247-
* @since 1.0
248230
*/
249231
public function setName(string $name) : bool {
250232
$keyValidity = self::isValidKey($name, $this->getStyle(), $this->getCase());
@@ -274,7 +256,7 @@ public function setName(string $name) : bool {
274256
* <li>none</li>
275257
* </ul>
276258
*
277-
* @since 1.0
259+
* @param string $lettersCase The case of the letters in the property name.
278260
*/
279261
public function setStyle(string $style, string $lettersCase = 'same') {
280262
$trimmed = strtolower(trim($style));
@@ -296,8 +278,6 @@ public function setStyle(string $style, string $lettersCase = 'same') {
296278
*
297279
* @param mixed $val The value of the property. This can be a string or
298280
* array or number or an object or null.
299-
*
300-
* @since 1.0
301281
*/
302282
public function setValue($val) {
303283
$this->datatype = gettype($val);
@@ -317,8 +297,6 @@ public function setValue($val) {
317297
*
318298
* @return bool|string If the key is valid, it will be returned
319299
* after trimmed. If not valid, false is returned.
320-
*
321-
* @since 1.0
322300
*/
323301
private static function isValidKey($key, $style = 'kebab', $case = 'same') {
324302
$trimmedKey = trim($key);

0 commit comments

Comments
 (0)