Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/palmtreephp/argparser
:palm_tree: Parse an array of arguments to call matching setter methods and/or merge with some defaults
https://github.com/palmtreephp/argparser
argparse argument-parser defaults
Last synced: about 1 month ago
JSON representation
:palm_tree: Parse an array of arguments to call matching setter methods and/or merge with some defaults
- Host: GitHub
- URL: https://github.com/palmtreephp/argparser
- Owner: palmtreephp
- License: mit
- Created: 2016-10-25T11:04:09.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-03-22T18:04:05.000Z (almost 4 years ago)
- Last Synced: 2024-04-05T16:03:03.838Z (9 months ago)
- Topics: argparse, argument-parser, defaults
- Language: PHP
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Palmtree ArgParser
[![License](http://img.shields.io/packagist/l/palmtree/argparser.svg)](LICENSE)
Parse an array of arguments and call matching setters and/or merge with default arguments.
## Requirements
* PHP >= 7.1## Installation
Use composer to add the package to your dependencies:
```bash
composer require palmtree/argparser
```## Usage
```php
false,
];private $name;
private $args = [];public function __construct($args = []) {
$parser = new ArgParser($args);$parser->parseSetters($this);
$this->args = $parser->resolveOptions(static::$defaultArgs);
}public function setName($name) {
$this->name = $name;
}
}
```
```php
setName('Andy') and sets the force arg to true
$obj = new SomeClass([
'name' => 'Andy',
'force' => true,
]);
```## License
Released under the [MIT license](LICENSE)