Skip to content

Commit 222d624

Browse files
committed
Merge branch 'release/0.2.5'
2 parents eb204ea + e567a64 commit 222d624

File tree

7 files changed

+154
-81
lines changed

7 files changed

+154
-81
lines changed

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "nonamephp/php7-common",
33
"description": "A collection of common PHP 7 libraries",
4-
"version": "0.2.4",
4+
"version": "0.2.5",
55
"license": "MIT",
66
"authors": [
77
{
@@ -15,7 +15,8 @@
1515
"php": ">=7.0"
1616
},
1717
"require-dev": {
18-
"phpunit/phpunit": "~4.0"
18+
"phpunit/phpunit": "~4.0",
19+
"squizlabs/php_codesniffer": "2.*"
1920
},
2021
"autoload": {
2122
"psr-4": {

phpcs.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Nonamephp coding standard">
3+
<description>Nonamephp coding standard</description>
4+
5+
<!-- command arguments -->
6+
<arg value="p"/>
7+
<arg name="colors"/>
8+
9+
<!-- inherit rules -->
10+
<rule ref="PSR2"/>
11+
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
12+
13+
<!-- include paths -->
14+
<file>src</file>
15+
<file>tests</file>
16+
</ruleset>

src/Collection.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function set($key, $value)
7777
*/
7878
public function get($key, $default = null)
7979
{
80-
if(isset($this->items[$key])){
80+
if (isset($this->items[$key])) {
8181
return $this->items[$key];
8282
}
8383
return $default;
@@ -153,21 +153,21 @@ public function is($key, $value, $operator = null) : bool
153153
{
154154
$keyValue = $this->get($key);
155155

156-
if(in_array($operator, [null, '=', '=='])){
156+
if (in_array($operator, [null, '=', '=='])) {
157157
return $keyValue == $value;
158-
}elseif($operator == '==='){ // strict
158+
} elseif ($operator == '===') { // strict
159159
return $keyValue === $value;
160-
}elseif($operator == '>'){
160+
} elseif ($operator == '>') {
161161
return $keyValue > $value;
162-
}elseif($operator == '>='){
162+
} elseif ($operator == '>=') {
163163
return $keyValue >= $value;
164-
}elseif($operator == '<'){
164+
} elseif ($operator == '<') {
165165
return $keyValue < $value;
166-
}elseif($operator == '<='){
166+
} elseif ($operator == '<=') {
167167
return $keyValue <= $value;
168-
}elseif(in_array($operator, ['!=', '<>'])){
168+
} elseif (in_array($operator, ['!=', '<>'])) {
169169
return $keyValue != $value;
170-
}else{
170+
} else {
171171
throw new \InvalidArgumentException('Invalid value supplied for $operator');
172172
}
173173
}
@@ -205,7 +205,7 @@ public function toArray() : array
205205

206206
public function getIterator()
207207
{
208-
foreach($this->items as $key => $value){
208+
foreach ($this->items as $key => $value) {
209209
yield $key => $value;
210210
}
211211
}
@@ -244,7 +244,7 @@ public function offsetUnset($offset)
244244
///////////////////////////////////
245245
// JsonSerializable Methods
246246

247-
function jsonSerialize()
247+
public function jsonSerialize()
248248
{
249249
return $this->toArray();
250250
}
@@ -261,4 +261,4 @@ public function unserialize($serialized)
261261
{
262262
$this->items = unserialize($serialized);
263263
}
264-
}
264+
}

src/Validator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
* @method static bool isNumeric(mixed $value, array $rule = []) Checks if value is numeric
2121
* @method static bool isFloat(mixed $value, array $rule = []) Checks if value is float
2222
* @method static bool isDouble(mixed $value, array $rule = []) Checks if value is double
23-
* @method static bool isAlNum(mixed $value, array $rule = []) Checks if value contains only alpha-numeric characters
24-
* @method static bool isAlphaNumeric(mixed $value, array $rule = []) Checks if value contains only alpha-numeric characters
23+
* @method static bool isAlNum(mixed $value, array $rule = []) Check for alpha-numeric characters only
24+
* @method static bool isAlphaNumeric(mixed $value, array $rule = []) Check for alpha-numeric characters only
2525
* @method static bool isAlpha(mixed $value, array $rule = []) Checks if value contains only alpha characters
2626
* @method static bool isArr(mixed $value, array $rule = []) Checks if value is an array
2727
* @method static bool isArray(mixed $value, array $rule = []) Checks if value is an array
@@ -133,7 +133,7 @@ public static function __callStatic($method, $arguments)
133133
}
134134
return (new self())->validateType($type, $value, $rule);
135135
}
136-
throw new \InvalidArgumentException("Validator::is() expects 2 or 3 parameters, $numArgs parameters were given.");
136+
throw new \InvalidArgumentException("Too many arguments passed to Validator::{$method}()");
137137
} else {
138138
// Handle call to Validator::is{Type}($value [, $rule])
139139
$type = implode('', $parts);
@@ -475,4 +475,4 @@ private function validateDateTime($value, array $rule = []) : bool
475475

476476
return true;
477477
}
478-
}
478+
}

tests/CollectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,4 @@ public function testMagicMethods()
221221
unset($collection['key1']);
222222
$this->assertFalse($collection->has('key1'));
223223
}
224-
}
224+
}

0 commit comments

Comments
 (0)