https://github.com/wyrihaximus/php-json-utilities
Utilities for php-json-* packages
https://github.com/wyrihaximus/php-json-utilities
hacktoberfest json php php5 php7
Last synced: about 1 year ago
JSON representation
Utilities for php-json-* packages
- Host: GitHub
- URL: https://github.com/wyrihaximus/php-json-utilities
- Owner: WyriHaximus
- License: mit
- Created: 2018-03-03T20:34:08.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-12-05T02:27:58.000Z (over 2 years ago)
- Last Synced: 2024-05-02T05:37:45.263Z (about 2 years ago)
- Topics: hacktoberfest, json, php, php5, php7
- Language: PHP
- Size: 332 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Utilities for my php-json-* packages

[](https://packagist.org/packages/WyriHaximus/json-utilities)
[](https://packagist.org/packages/WyriHaximus/json-utilities)
[](https://scrutinizer-ci.com/g/WyriHaximus/php-json-utilities/?branch=master)
[](https://packagist.org/packages/wyrihaximus/json-utilities)
[](https://travis-ci.org/WyriHaximus/php-json-utilities)
### Installation ###
To install via [Composer](http://getcomposer.org/), use the command below, it will automatically detect the latest version and bind it with `~`.
```
composer require wyrihaximus/json-utilities
```
# Available functions
### validate_array
Validates an array by checking if the list of required keys all can be found in the passed array. On success it will
return `true`, when it comes across a key it can find in the array it will return `false`. How ever then passed an
exception it will create that exception by passing the array as first argument and the missing key as second argument
to the constructor.
```php
$array = ['key', 'another_key', 'required_key']; //
$requiredKeys = ['required_key'];
validate_array($array, $requiredKeys, ExceptionToBeTrownWhenAKeyIsMissing::class);
```
## Contributing ##
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## License ##
Copyright 2018 [Cees-Jan Kiewiet](http://wyrihaximus.net/)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.