Skip to content

Commit

Permalink
chore: cleanup with extra strict pint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyMckenzie committed Mar 5, 2024
1 parent a83f9a2 commit 4d81358
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 25 deletions.
43 changes: 41 additions & 2 deletions pint.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
{
"preset": "laravel"
}
"preset": "laravel",
"rules": {
"array_push": true,
"backtick_to_shell_exec": true,
"declare_strict_types": true,
"final_class": true,
"fully_qualified_strict_types": true,
"global_namespace_import": {
"import_classes": true,
"import_constants": true,
"import_functions": true
},
"ordered_class_elements": {
"order": [
"use_trait",
"case",
"constant",
"constant_public",
"constant_protected",
"constant_private",
"property_public",
"property_protected",
"property_private",
"construct",
"destruct",
"magic",
"phpunit",
"method_abstract",
"method_public_static",
"method_public",
"method_protected_static",
"method_protected",
"method_private_static",
"method_private"
],
"sort_algorithm": "none"
},
"ordered_interfaces": true,
"ordered_traits": true
}
}
16 changes: 8 additions & 8 deletions src/ValueObjects/Connector/BaseUri.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ private function __construct(private string $baseUri)
{
}

/**
* Creates a new Base URI value object.
*/
public static function from(string $baseUri): self
{
return new self($baseUri);
}

#[Override]
public function __toString(): string
{
Expand All @@ -40,4 +32,12 @@ public function __toString(): string

return "https://$this->baseUri/";
}

/**
* Creates a new Base URI value object.
*/
public static function from(string $baseUri): self
{
return new self($baseUri);
}
}
4 changes: 2 additions & 2 deletions src/ValueObjects/Connector/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* Creates a new Response value object.
*
* @param TData $data
* @param TData $data
*/
private function __construct(private mixed $data)
{
Expand All @@ -27,7 +27,7 @@ private function __construct(private mixed $data)
/**
* Creates a new Response value object from the given data and meta information.
*
* @param TData $attributes
* @param TData $attributes
* @return Response<TData>
*/
public static function from(array $attributes): self
Expand Down
12 changes: 6 additions & 6 deletions src/ValueObjects/ResourceUri.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ private function __construct(private string $uri)
{
}

#[Override]
public function __toString(): string
{
return $this->uri;
}

/**
* Creates a new resource URI value object that lists the given resource.
*/
Expand All @@ -40,10 +46,4 @@ public static function retrieve(string $resource, string $id): self
{
return new self("$resource/$id");
}

#[Override]
public function __toString(): string
{
return $this->uri;
}
}
12 changes: 6 additions & 6 deletions src/ValueObjects/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@
*/
private const int PATCH = 0;

#[Override]
public function __toString(): string
{
return self::MAJOR.'.'.self::MINOR.'.'.self::PATCH;
}

/**
* Constructs a new version based on the major, minor, and patch of the current release.
*/
public static function current(): string
{
return (string) new self();
}

#[Override]
public function __toString(): string
{
return self::MAJOR.'.'.self::MINOR.'.'.self::PATCH;
}
}
2 changes: 2 additions & 0 deletions tests/Pest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests;

/*
Expand Down
2 changes: 2 additions & 0 deletions tests/Resources/AutocompleteBreweries.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Resources;

use OpenBreweryDb\OpenBreweryDb;
Expand Down
4 changes: 3 additions & 1 deletion tests/Resources/FindBrewery.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Resources;

use OpenBreweryDb\Exceptions\ErrorException;
Expand Down Expand Up @@ -30,6 +32,6 @@
$client = OpenBreweryDb::client();

// Act/Assert
expect(fn() => $client->breweries()->find('not-a-brewery'))->toThrow(ErrorException::class, 'Couldn\'t find Brewery');
expect(fn () => $client->breweries()->find('not-a-brewery'))->toThrow(ErrorException::class, 'Couldn\'t find Brewery');
});
});
2 changes: 2 additions & 0 deletions tests/Resources/ListBreweries.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Resources;

use OpenBreweryDb\Client;
Expand Down
2 changes: 2 additions & 0 deletions tests/Resources/MetadataBreweries.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Resources;

use OpenBreweryDb\OpenBreweryDb;
Expand Down
2 changes: 2 additions & 0 deletions tests/Resources/RandomBreweries.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Resources;

use OpenBreweryDb\Client;
Expand Down
2 changes: 2 additions & 0 deletions tests/Resources/SearchBreweries.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Tests\Resources;

use OpenBreweryDb\OpenBreweryDb;
Expand Down

0 comments on commit 4d81358

Please sign in to comment.