Skip to content

Commit

Permalink
Review code (#43)
Browse files Browse the repository at this point in the history
* remove useless comments
* update composer.json
* update README
* clean test files with linter
* remove option --no-suggest from github action
* remove token for codecov
* explain codeCoverageIgnore
* remove mesage trait in request trait (no trait inside another)
* update http phrases
* use public url and local php server for client tests
* catch ValueError from fopen (php8)
  • Loading branch information
rancoud authored Apr 26, 2021
1 parent b53beb2 commit 4846b11
Show file tree
Hide file tree
Showing 30 changed files with 797 additions and 707 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
restore-keys: ${{ runner.os }}-${{ matrix.php-version }}-composer-

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
run: composer install --prefer-dist --no-progress

- name: Lint
run: |
Expand All @@ -57,5 +57,4 @@ jobs:
uses: codecov/[email protected]
if: success()
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage/clover.xml
76 changes: 38 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ composer require rancoud/http

## How to use it?
```php
$factory = new Rancoud\Http\Message\Factory();
$factory = new Rancoud\Http\Message\Factory\Factory();
$request = $factory->createRequest('GET', 'https://example.com');
$stream = $factory->createStream('foobar');
```
Expand Down Expand Up @@ -51,17 +51,17 @@ $stream = $factory->createStream('foobar');
## Request
### Constructor
#### Mandatory
| Parameter | Type | Description |
| --- | --- | --- |
| method | string | HTTP method |
| uri | mixed | Uri |
| Parameter | Type | Description |
| --------- | ------ | ----------- |
| method | string | HTTP method |
| uri | mixed | Uri |

#### Optionnals
| Parameter | Type | Default value | Description |
| --- | --- | --- | --- |
| headers | array | [] | Request headers |
| body | mixed | [] | Request body |
| version | string | '1.1' | HTTP protocol version |
| Parameter | Type | Default value | Description |
| --------- | ------ | ------------- | --------------------- |
| headers | array | [] | Request headers |
| body | mixed | [] | Request body |
| version | string | '1.1' | HTTP protocol version |

### Methods
* getBody(): StreamInterface
Expand Down Expand Up @@ -139,13 +139,13 @@ $stream = $factory->createStream('foobar');
## Response
### Constructor
#### Optionnals
| Parameter | Type | Default value | Description |
| --- | --- | --- | --- |
| status | int | 200 | Status code |
| headers | array | [] | Response headers |
| body | mixed | [] | Response body |
| version | string | '1.1' | HTTP protocol version |
| reason | string | null | String send after status code |
| Parameter | Type | Default value | Description |
| --------- | ------ | ------------- | ----------------------------- |
| status | int | 200 | Status code |
| headers | array | [] | Response headers |
| body | mixed | [] | Response body |
| version | string | '1.1' | HTTP protocol version |
| reason | string | null | String send after status code |

### Methods
* getBody(): StreamInterface
Expand Down Expand Up @@ -326,18 +326,18 @@ $stream = $factory->createStream('foobar');
## ServerRequest
### Constructor
#### Mandatory
| Parameter | Type | Description |
| --- | --- | --- |
| method | string | HTTP method |
| uri | mixed | Uri |
| Parameter | Type | Description |
| --------- | ------ | ----------- |
| method | string | HTTP method |
| uri | mixed | Uri |

#### Optionnals
| Parameter | Type | Default value | Description |
| --- | --- | --- | --- |
| headers | array | [] | Request headers |
| body | mixed | [] | Request body |
| version | string | '1.1' | HTTP protocol version |
| serverParams | array | [] | Server parameters |
| Parameter | Type | Default value | Description |
| ------------ | ------ | ------------- | --------------------- |
| headers | array | [] | Request headers |
| body | mixed | [] | Request body |
| version | string | '1.1' | HTTP protocol version |
| serverParams | array | [] | Server parameters |

### Methods
* getAttribute(name: string, [default: mixed = null]): mixed|null
Expand Down Expand Up @@ -396,17 +396,17 @@ $stream = $factory->createStream('foobar');
## UploadedFile
### Constructor
#### Mandatory
| Parameter | Type | Description |
| --- | --- | --- |
| Parameter | Type | Description |
| ------------ | ----- | -------------- |
| streamOrFile | mixed | Stream or file |
| size | int | Filesize |
| errorStatus | int | Upload errors |
| size | int | Filesize |
| errorStatus | int | Upload errors |

#### Optionnals
| Parameter | Type | Default value | Description |
| --- | --- | --- | --- |
| clientFilename | string\|null | null | Filename |
| clientMediaType | string\|null | null | Media type |
| Parameter | Type | Default value | Description |
| --------------- | ------------ | ------------- | ----------- |
| clientFilename | string\|null | null | Filename |
| clientMediaType | string\|null | null | Media type |

### Methods
* getClientFilename(): ?string
Expand All @@ -430,9 +430,9 @@ $stream = $factory->createStream('foobar');
## Uri
### Constructor
#### Optionnals
| Parameter | Type | Default value | Description |
| --- | --- | --- | --- |
| uri | string | '' | Uri |
| Parameter | Type | Default value | Description |
| --------- | ------ | ------------- | ----------- |
| uri | string | '' | Uri |

### Methods
* __toString(): string
Expand Down
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@
"Psr\\Http\\": "src/Psr"
}
},
"autoload-dev": {
"psr-4": {
"tests\\": "tests"
}
},
"require": {
"php": ">=7.4.0",
"ext-curl": "*"
"ext-curl": "*",
"ext-mbstring": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
"phpunit/phpunit": "^9.2",
"squizlabs/php_codesniffer": "^3.5"
"squizlabs/php_codesniffer": "^3.5",
"symfony/process": "^5.2"
},
"provide": {
"psr/http-message-implementation": "1.0",
Expand Down
Loading

0 comments on commit 4846b11

Please sign in to comment.