Skip to content

Commit

Permalink
Merge pull request #17 from rayanlevert/feature/enum-options
Browse files Browse the repository at this point in the history
Arguments\Option : Enumeration to describe all defined options for an Argument
  • Loading branch information
rayanlevert authored Aug 17, 2024
2 parents 7f5a54f + b15cc27 commit dc99c0e
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 349 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml → .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Inspired by Sebastian Bergmann's phpunit action workflow https://github.com/sebastianbergmann/phpunit/blob/main/.github/workflows/ci.yml
# Inspired by Sebastian Bergmann's phpunit action workflow https://github.com/sebastianbergmann/phpunit/blob/main/.github/workflows/ci.yaml

name: "CI"

Expand Down Expand Up @@ -97,6 +97,7 @@ jobs:
- "8.1"
- "8.2"
- "8.3"
- "8.4"

steps:
- name: Checkout
Expand Down
202 changes: 0 additions & 202 deletions README.md

This file was deleted.

18 changes: 1 addition & 17 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
version: '2'

services:
cli-8.1:
build: docker/8.1
restart: 'no'
working_dir: /app
volumes:
- .:/app

cli-8.2:
build: docker/8.2
restart: 'no'
working_dir: /app
volumes:
- .:/app

cli-8.3:
cli:
build: docker/8.3
restart: 'no'
working_dir: /app
Expand Down
24 changes: 0 additions & 24 deletions docker/8.1/Dockerfile

This file was deleted.

24 changes: 0 additions & 24 deletions docker/8.2/Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions docker/8.3/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM composer:2.6.5 AS composer
FROM php:8.3-fpm
FROM composer:2.7.7 AS composer
FROM php:8.3-cli

LABEL maintainer="Rayan Levert <[email protected]>"

Expand Down
20 changes: 10 additions & 10 deletions src/Arguments.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @implements \IteratorAggregate<string, Argument>
*/
class Arguments implements \IteratorAggregate
class Arguments implements \IteratorAggregate, \Countable
{
/**
* @var array<string, Argument>
Expand All @@ -43,11 +43,11 @@ public function __construct(Argument ...$oArguments)
}

/**
* @return \Traversable<string, Argument>
* @return \Generator<string, Argument>
*/
public function getIterator(): \Traversable
public function getIterator(): \Generator
{
return new \ArrayIterator($this->data);
yield from $this->data;
}

/**
Expand Down Expand Up @@ -121,7 +121,7 @@ public function parse(string ...$arguments): void
}

// Loops to recover required arguments and set their values
foreach ($this->data as $name => $oArgument) {
foreach ($this as $name => $oArgument) {
if (!$oArgument->isRequired()) {
continue;
}
Expand Down Expand Up @@ -171,7 +171,7 @@ public function getRequired(): self

$oSelf = new self();

foreach ($this->data as $oArgument) {
foreach ($this as $oArgument) {
if ($oArgument->isRequired()) {
$oSelf->set($oArgument);
}
Expand Down Expand Up @@ -215,7 +215,7 @@ public function printArguments(): void
*/
protected function getByShortPrefix(string $name): ?Argument
{
foreach ($this->data as $oArgument) {
foreach ($this as $oArgument) {
if ($oArgument->getPrefix() === $name) {
return $oArgument;
}
Expand All @@ -229,7 +229,7 @@ protected function getByShortPrefix(string $name): ?Argument
*/
protected function getByLongPrefix(string $name): ?Argument
{
foreach ($this->data as $oArgument) {
foreach ($this as $oArgument) {
if ($oArgument->getLongPrefix() === $name) {
return $oArgument;
}
Expand All @@ -245,7 +245,7 @@ protected function getNotHandled(): self
{
$oSelf = new self();

foreach ($this->data as $oArgument) {
foreach ($this as $oArgument) {
if (!$oArgument->hasBeenHandled()) {
$oSelf->set($oArgument);
}
Expand All @@ -269,7 +269,7 @@ protected function assertOrderRequired(): void
{
$argHasNotRequired = false;

foreach ($this->data as $name => $oArgument) {
foreach ($this as $name => $oArgument) {
if ($oArgument->getPrefix() || $oArgument->getLongPrefix()) {
continue;
}
Expand Down
Loading

0 comments on commit dc99c0e

Please sign in to comment.