Skip to content

Commit 30e5d12

Browse files
committed
fix code style
1 parent 93e44a0 commit 30e5d12

7 files changed

Lines changed: 35 additions & 36 deletions

File tree

src/Client.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
final class Client
1515
{
1616
private HttpClient $http;
17+
1718
private Config $config;
1819

1920
public function __construct(string $apiToken, ?Config $config = null)
@@ -23,7 +24,7 @@ public function __construct(string $apiToken, ?Config $config = null)
2324
'base_uri' => $this->config->baseUrl,
2425
'timeout' => $this->config->timeout,
2526
'headers' => [
26-
'Authorization' => 'Bearer ' . $this->config->apiToken,
27+
'Authorization' => 'Bearer '.$this->config->apiToken,
2728
'Content-Type' => 'application/json',
2829
],
2930
]);
@@ -33,6 +34,7 @@ public function __construct(string $apiToken, ?Config $config = null)
3334
* Search for suppliers.
3435
*
3536
* @return Supplier[]
37+
*
3638
* @throws ApiException
3739
* @throws RateLimitException
3840
* @throws InvalidQueryException
@@ -68,7 +70,7 @@ public function search(
6870

6971
$result = json_decode($response->getBody()->getContents(), true);
7072

71-
if (!isset($result['data']['defaultDatasetId'])) {
73+
if (! isset($result['data']['defaultDatasetId'])) {
7274
throw new ApiException('Invalid API response: missing dataset ID');
7375
}
7476

@@ -80,6 +82,7 @@ public function search(
8082

8183
/**
8284
* @return Supplier[]
85+
*
8386
* @throws ApiException
8487
*/
8588
private function fetchDataset(string $datasetId): array
@@ -89,11 +92,11 @@ private function fetchDataset(string $datasetId): array
8992
$items = json_decode($response->getBody()->getContents(), true);
9093

9194
return array_map(
92-
static fn(array $item) => Supplier::fromArray($item),
95+
static fn (array $item) => Supplier::fromArray($item),
9396
$items
9497
);
9598
} catch (GuzzleException $e) {
96-
throw new ApiException('Failed to fetch dataset: ' . $e->getMessage(), 0, $e);
99+
throw new ApiException('Failed to fetch dataset: '.$e->getMessage(), 0, $e);
97100
}
98101
}
99102

@@ -114,6 +117,6 @@ private function handleGuzzleException(GuzzleException $e): never
114117
}
115118
}
116119

117-
throw new ApiException('API request failed: ' . $e->getMessage(), 0, $e);
120+
throw new ApiException('API request failed: '.$e->getMessage(), 0, $e);
118121
}
119122
}

src/DTO/Supplier.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
final readonly class Supplier
1010
{
1111
/**
12-
* @param Heading[] $headings
13-
* @param Certification[] $certifications
14-
* @param CertificationTotal[] $certificationTotals
15-
* @param Product[] $products
16-
* @param Person[] $personnel
17-
* @param Brand[] $brands
18-
* @param SocialLink[] $social
19-
* @param Video[] $videos
20-
* @param NewsArticle[] $news
21-
* @param Whitepaper[] $whitepapers
22-
* @param string[] $otherActivities
12+
* @param Heading[] $headings
13+
* @param Certification[] $certifications
14+
* @param CertificationTotal[] $certificationTotals
15+
* @param Product[] $products
16+
* @param Person[] $personnel
17+
* @param Brand[] $brands
18+
* @param SocialLink[] $social
19+
* @param Video[] $videos
20+
* @param NewsArticle[] $news
21+
* @param Whitepaper[] $whitepapers
22+
* @param string[] $otherActivities
2323
*/
2424
public function __construct(
2525
public string $tgramsId,
@@ -75,43 +75,43 @@ public static function fromArray(array $data): self
7575
logoTitle: $data['logoTitle'] ?? null,
7676
address: Address::fromArray($data['address'] ?? []),
7777
headings: array_map(
78-
static fn(array $h) => Heading::fromArray($h),
78+
static fn (array $h) => Heading::fromArray($h),
7979
$data['headings'] ?? []
8080
),
8181
certifications: array_map(
82-
static fn(array $c) => Certification::fromArray($c),
82+
static fn (array $c) => Certification::fromArray($c),
8383
$data['certifications'] ?? []
8484
),
8585
certificationTotals: array_map(
86-
static fn(array $ct) => CertificationTotal::fromArray($ct),
86+
static fn (array $ct) => CertificationTotal::fromArray($ct),
8787
$data['certificationTotals'] ?? []
8888
),
8989
products: array_map(
90-
static fn(array $p) => Product::fromArray($p),
90+
static fn (array $p) => Product::fromArray($p),
9191
$data['products'] ?? []
9292
),
9393
personnel: array_map(
94-
static fn(array $p) => Person::fromArray($p),
94+
static fn (array $p) => Person::fromArray($p),
9595
$data['personnel'] ?? []
9696
),
9797
brands: array_map(
98-
static fn(array $b) => Brand::fromArray($b),
98+
static fn (array $b) => Brand::fromArray($b),
9999
$data['brands'] ?? []
100100
),
101101
social: array_map(
102-
static fn(array $s) => SocialLink::fromArray($s),
102+
static fn (array $s) => SocialLink::fromArray($s),
103103
$data['social'] ?? []
104104
),
105105
videos: array_map(
106-
static fn(array $v) => Video::fromArray($v),
106+
static fn (array $v) => Video::fromArray($v),
107107
$data['videos'] ?? []
108108
),
109109
news: array_map(
110-
static fn(array $n) => NewsArticle::fromArray($n),
110+
static fn (array $n) => NewsArticle::fromArray($n),
111111
$data['news'] ?? []
112112
),
113113
whitepapers: array_map(
114-
static fn(array $w) => Whitepaper::fromArray($w),
114+
static fn (array $w) => Whitepaper::fromArray($w),
115115
$data['whitepapers'] ?? []
116116
),
117117
otherActivities: $data['otherActivities'] ?? [],

src/Exception/ApiException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,4 @@
66

77
use Exception;
88

9-
class ApiException extends Exception
10-
{
11-
}
9+
class ApiException extends Exception {}

src/Exception/InvalidQueryException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@
44

55
namespace ThomasNetScraper\Exception;
66

7-
class InvalidQueryException extends ApiException
8-
{
9-
}
7+
class InvalidQueryException extends ApiException {}

tests/EnumTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
declare(strict_types=1);
44

5-
use ThomasNetScraper\SearchMode;
65
use ThomasNetScraper\Area;
6+
use ThomasNetScraper\SearchMode;
77

88
it('has correct search mode values', function () {
99
expect(SearchMode::All->value)->toBe('all')

tests/SimpleDtoTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
use ThomasNetScraper\DTO\Brand;
66
use ThomasNetScraper\DTO\Person;
7+
use ThomasNetScraper\DTO\Product;
78
use ThomasNetScraper\DTO\SocialLink;
89
use ThomasNetScraper\DTO\Video;
9-
use ThomasNetScraper\DTO\Product;
1010

1111
describe('Brand', function () {
1212
it('creates brand from array', function () {

tests/SupplierTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
declare(strict_types=1);
44

5-
use ThomasNetScraper\DTO\Supplier;
65
use ThomasNetScraper\DTO\Address;
6+
use ThomasNetScraper\DTO\Brand;
77
use ThomasNetScraper\DTO\Certification;
88
use ThomasNetScraper\DTO\Heading;
9-
use ThomasNetScraper\DTO\Brand;
109
use ThomasNetScraper\DTO\NewsArticle;
10+
use ThomasNetScraper\DTO\Supplier;
1111
use ThomasNetScraper\DTO\Whitepaper;
1212

1313
it('creates supplier from array', function () {

0 commit comments

Comments
 (0)