Skip to content

Commit

Permalink
Improve documentation v2
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Dec 2, 2024
1 parent fe05197 commit a7f5cb8
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 15 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ composer require bakame/http-structured-fields

## Documentation

- The documentation for [version 2.x](/docs/00-intro.md) for **the upcoming v2 release**
- The documentation for [version 1.x](https://github.com/bakame-php/http-structured-fields/tree/1.x) for the current stable version.
- The documentation for **the upcoming [version 2.x](/docs/index) release**

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion docs/01-basic-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ process that the package can simplify for you once you read the documentation.
The goal of the examples are to show that even without dwelling too much into the ins and out
of the package you can easily and quickly parse or serialize compliant fields in PHP.

← [Intro](00-intro.md) | [Parsing and Serializing](02-parsing-serializing.md) →
← [Intro](index) | [Parsing and Serializing](02-parsing-serializing.md) →
2 changes: 1 addition & 1 deletion docs/04-containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,4 +456,4 @@ Item::new($cache->name)
->when(null !== $cache->detail, fn (Item $item) => $item->appendParameter('detail', $cache->detail));
```

← [Accessing Field Values](03-field-values.md) | [Validation](05-validation) →
← [Accessing Field Values](03-field-values.md) | [Validation](05-validation.md) →
2 changes: 1 addition & 1 deletion docs/08-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,4 @@ OuterList::fromPairs([
> [!NOTE]
> The v1 syntax is still supported.
← [Extending the package functionalities](07-extensions.md) | [Intro](00-intro.md) →
← [Extending the package functionalities](07-extensions.md) | [Intro](index) →
8 changes: 8 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
permalink: pretty
remote_theme: pages-themes/hacker@v0.2.0
plugins:
- jekyll-redirect-from
- jekyll-remote-theme # add this line to the plugins list if you already have one
title: bakame/http-structured-fields
description: is a framework-agnostic PHP library that allows you to parse, serialize, create, update and validate HTTP Structured Fields in PHP
File renamed without changes.
6 changes: 3 additions & 3 deletions src/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
*/
enum Type: string
{
public const MAXIMUM_INT = 999_999_999_999_999;
public const MAXIMUM_FLOAT = 999_999_999_999;
private const MAXIMUM_INT = 999_999_999_999_999;
private const MAXIMUM_FLOAT = 999_999_999_999;

case Integer = 'integer';
case Decimal = 'decimal';
Expand Down Expand Up @@ -45,7 +45,7 @@ public function isOneOf(mixed ...$other): bool
/**
* @throws SyntaxError if the value can not be resolved into a supported HTTP structured field data type
*/
public static function fromVariable(mixed $value): self
public static function fromVariable(Item|Token|DisplayString|Bytes|DateTimeInterface|int|float|bool|string $value): self
{
return self::tryFromVariable($value) ?? throw new SyntaxError(match (true) {
$value instanceof DateTimeInterface => 'The integer representation of a date is limited to 15 digits for a HTTP structured field date type.',
Expand Down
8 changes: 1 addition & 7 deletions tests/TypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@

final class TypeTest extends TestCase
{
#[Test]
public function it_will_return_null_if_the_type_is_no_supported(): void
{
self::assertNull(Type::tryFromVariable([]));
}

#[Test]
public function it_will_return_false_if_the_type_is_valid_but_its_value_is_invalid(): void
{
Expand All @@ -35,7 +29,7 @@ public function it_can_tell_the_item_type_from_a_value_instance(): void
#[DataProvider('itemTypeProvider')]
public function it_can_tell_the_item_type(mixed $value, Type $expectedType): void
{
self::assertTrue($expectedType->equals(Type::fromVariable($value)));
self::assertTrue($expectedType->equals(Type::fromVariable($value))); /* @phpstan-ignore-line */
self::assertTrue($expectedType->equals(Type::tryFromVariable($value)));
}

Expand Down

0 comments on commit a7f5cb8

Please sign in to comment.