Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

Commit 1338a60

Browse files
Merge branch 'release/2.0.0'
2 parents afcdf32 + 2f740b8 commit 1338a60

File tree

8 files changed

+63
-43
lines changed

8 files changed

+63
-43
lines changed

.travis.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
language: php
22

33
php:
4-
- 7.2
5-
- nightly
4+
- "7.2"
5+
- "7.3"
6+
- 7.4snapshot
67

78
cache:
89
directories:
@@ -15,10 +16,11 @@ env:
1516

1617
matrix:
1718
allow_failures:
18-
- php: nightly
19+
- php: 7.4snapshot
1920
fast_finish: true
2021

2122
before_install:
23+
- composer validate --strict
2224
- travis_retry composer self-update
2325

2426
install:

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,21 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
66

77
## Unreleased
88

9+
## 2.0.0 (2019-02-27)
10+
11+
### Changed
12+
13+
- Renamed `Constants` to `Enum` to better reflect their purpose
14+
- Upgraded to PHPUnit 8
15+
- Test against PHP 7.3 and 7.4
16+
917
## 1.0.0 (2018-07-22)
1018

1119
### Added
1220

1321
- rand_bool helper
1422
- str_wrap helper
15-
_ is\_assoc\_array helper
23+
- is\_assoc\_array helper
1624
- array_expand helper
1725
- array_without helper
1826
- array\_pull\_value helper

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -377,35 +377,35 @@ See the [ddd helper](#ddd) for example output.
377377

378378
## Class helpers
379379

380-
### Constants trait
380+
### Enum trait
381381

382-
The primary use of the `Constants` trait is to enable you to store all constants of a specific type in a single class or value object and have it return those with a single call.
382+
The primary use of the `Enum` trait is to enable you to store all cases of a specific type in a single class or value object and have it return those with a single call.
383383

384-
This can be useful for instance when your database uses integers to store states, but you want to use descriptive strings throughout your code (i.e. enums). It also allows you to refactor these constants at any time without having to waste time searching your code for any raw values (and probably miss a few, introducing new bugs along the way).
384+
This can be useful for instance when your database uses integers to store states, but you want to use descriptive strings throughout your code (i.e. enums). It also allows you to refactor these elements at any time without having to waste time searching your code for any raw values (and probably miss a few, introducing new bugs along the way).
385385

386-
#### Retrieving constants
386+
#### Retrieving elements
387387

388-
Returns an array of constant keys and their values.
388+
Returns an array of element keys and their values.
389389

390390
```php
391391
<?php
392392

393-
use SebastiaanLuca\PhpHelpers\Classes\Constants;
393+
use SebastiaanLuca\PhpHelpers\Classes\Enum;
394394

395395
class UserStates
396396
{
397-
use Constants;
397+
use Enum;
398398

399399
public const REGISTERED = 'registered';
400400
public const ACTIVATED = 'activated';
401401
public const DISABLED = 'disabled';
402402
}
403403

404-
UserStates::constants();
404+
UserStates::enums();
405405

406406
// or
407407

408-
(new UserStates)->constants();
408+
(new UserStates)->enums();
409409

410410
/*
411411
[
@@ -416,18 +416,18 @@ UserStates::constants();
416416
*/
417417
```
418418

419-
#### Retrieving constant keys
419+
#### Retrieving element keys
420420

421-
Returns all the keys of constants in a class.
421+
Returns all the keys of the elements in an enum.
422422

423423
```php
424424
<?php
425425

426-
use SebastiaanLuca\PhpHelpers\Classes\Constants;
426+
use SebastiaanLuca\PhpHelpers\Classes\Enum;
427427

428428
class UserStates
429429
{
430-
use Constants;
430+
use Enum;
431431

432432
public const REGISTERED = 'registered';
433433
public const ACTIVATED = 'activated';
@@ -447,16 +447,16 @@ UserStates::keys();
447447

448448
#### Retrieving constant values
449449

450-
Returns all the values of constants in a class.
450+
Returns all the values of the elements in an enum.
451451

452452
```php
453453
<?php
454454

455-
use SebastiaanLuca\PhpHelpers\Classes\Constants;
455+
use SebastiaanLuca\PhpHelpers\Classes\Enum;
456456

457457
class UserStates
458458
{
459-
use Constants;
459+
use Enum;
460460

461461
public const REGISTERED = 'registered';
462462
public const ACTIVATED = 'activated';
@@ -561,7 +561,7 @@ composer test
561561

562562
## Contributing
563563

564-
Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.
564+
Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE OF CONDUCT](CODE_OF_CONDUCT.md) for details.
565565

566566
## Security
567567

composer.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
"php": "^7.2"
2727
},
2828
"require-dev": {
29-
"kint-php/kint": "^2.2",
30-
"nesbot/carbon": "^1.22",
31-
"phpunit/phpunit": "^7.2"
29+
"kint-php/kint": "^3.1",
30+
"nesbot/carbon": "^1.22|^2.0",
31+
"phpunit/phpunit": "^8.0"
3232
},
3333
"suggest": {
3434
"kint-php/kint": "A powerful and modern PHP debugging tool. Required for the debug helpers.",
@@ -48,10 +48,18 @@
4848
"SebastiaanLuca\\PhpHelpers\\Tests\\": "tests"
4949
}
5050
},
51-
"scripts": {
52-
"test": "vendor/bin/phpunit"
53-
},
5451
"config": {
5552
"sort-packages": true
53+
},
54+
"scripts": {
55+
"test": "vendor/bin/phpunit",
56+
"test-lowest": [
57+
"composer update --prefer-lowest --prefer-dist --no-interaction --ansi",
58+
"@test"
59+
],
60+
"test-stable": [
61+
"composer update --prefer-stable --prefer-dist --no-interaction --ansi",
62+
"@test"
63+
]
5664
}
5765
}

phpunit.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
stopOnFailure="false"
1414
failOnRisky="true"
1515
failOnWarning="true"
16-
stopOnError="false">
16+
stopOnError="false"
17+
cacheResult="false"
18+
cacheTokens="false">
1719
<testsuites>
1820
<testsuite name="Feature Tests">
1921
<directory suffix="Test.php">./tests/Feature</directory>

src/Classes/Constants.php renamed to src/Classes/Enum.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,35 @@
44

55
use ReflectionClass;
66

7-
trait Constants
7+
trait Enum
88
{
99
/**
10-
* Get all the class constants.
10+
* Get all the elements of the enumerator.
1111
*
1212
* @return array
1313
*/
14-
public static function constants() : array
14+
public static function enums() : array
1515
{
1616
return (new ReflectionClass(__CLASS__))->getConstants();
1717
}
1818

1919
/**
20-
* Get all the names of the class constants.
20+
* Get all the names of the elements.
2121
*
2222
* @return array
2323
*/
2424
public static function keys() : array
2525
{
26-
return array_keys(static::constants());
26+
return array_keys(static::enums());
2727
}
2828

2929
/**
30-
* Get all the values of the class constants.
30+
* Get all the values of the elements.
3131
*
3232
* @return array
3333
*/
3434
public static function values() : array
3535
{
36-
return array_values(static::constants());
36+
return array_values(static::enums());
3737
}
3838
}

tests/Unit/Classes/ConstantsHelperTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace SebastiaanLuca\Helpers\Tests\Unit\Classes;
44

5-
use SebastiaanLuca\PhpHelpers\Classes\Constants;
5+
use SebastiaanLuca\PhpHelpers\Classes\Enum;
66
use SebastiaanLuca\PhpHelpers\Tests\TestCase;
77

88
class ConstantsHelperTest extends TestCase
@@ -14,7 +14,7 @@ public function it returns all constants() : void
1414
{
1515
$class = new class
1616
{
17-
use Constants;
17+
use Enum;
1818

1919
public const FIRST_CONSTANT = 1;
2020
public const SECOND_CONSTANT = 2;
@@ -25,7 +25,7 @@ public function it returns all constants() : void
2525
'FIRST_CONSTANT' => 1,
2626
'SECOND_CONSTANT' => 2,
2727
'THIRD_CONSTANT' => 3,
28-
], $class::constants());
28+
], $class::enums());
2929
}
3030

3131
/**
@@ -35,7 +35,7 @@ public function it returns all constant names() : void
3535
{
3636
$class = new class
3737
{
38-
use Constants;
38+
use Enum;
3939

4040
public const FIRST_CONSTANT = 1;
4141
public const SECOND_CONSTANT = 2;
@@ -56,7 +56,7 @@ public function it returns all constant values() : void
5656
{
5757
$class = new class
5858
{
59-
use Constants;
59+
use Enum;
6060

6161
public const FIRST_CONSTANT = 1;
6262
public const SECOND_CONSTANT = 'two';

tests/Unit/Functions/GenericHelpersTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class GenericHelpersTest extends TestCase
1212
*/
1313
public function rand_bool returns a random bool() : void
1414
{
15-
$this->assertInternalType('bool', rand_bool());
15+
$this->assertIsBool(rand_bool());
1616
}
1717

1818
/**
@@ -153,9 +153,9 @@ public function temporary_file creates a temporary file and returns its 
153153
$this->assertArrayHasKey('file', $file);
154154
$this->assertArrayHasKey('path', $file);
155155

156-
$this->assertInternalType('resource', $file['file']);
156+
$this->assertIsResource($file['file']);
157157

158-
$this->assertInternalType('string', $file['path']);
158+
$this->assertIsString($file['path']);
159159
$this->assertFileExists($file['path']);
160160
}
161161

0 commit comments

Comments
 (0)