-
Notifications
You must be signed in to change notification settings - Fork 156
Adds assertion to check all keys exist in an array #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
junaidbinfarooq
commented
Jan 3, 2023
- Adds the assertion to assert if all the provided keys exist in the given array
shadowhand
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this idea, but a couple of things:
- It needs to be rebased to current
master. - Return type needs to be added.
- The type needs to be changed.
- The mixin needs to be regenerated with
php bin/generate.php.
f3066ad to
9bd7b44
Compare
@shadowhand |
- Adds the assertion to assert if all the provided keys exist in the given array - Adds types - Regenerates mixin
9bd7b44 to
1736b76
Compare
| * | ||
| * @throws InvalidArgumentException | ||
| */ | ||
| public static function KeysExist(mixed $array, array $keys, string $message = ''): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be camelCase, keysExist.
| static::isArray($array); | ||
|
|
||
| foreach ($keys as $key) { | ||
| static::keyExists($array, $key, $message ?: 'Expected the key %s to exist.',); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| static::keyExists($array, $key, $message ?: 'Expected the key %s to exist.',); | |
| static::keyExists($array, $key, $message); |
|
@junaidbinfarooq need to add unit tests as well, and correct existing test failures. |