Skip to content

Commit a626260

Browse files
author
Tyler King
committed
Merge branch 'master' of github.com:osiset/Basic-Shopify-API
2 parents eeefa57 + 3043ef7 commit a626260

File tree

12 files changed

+73
-67
lines changed

12 files changed

+73
-67
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
normalize: true
2525
validate: true
2626

27-
name: PHP ${{ matrix.php-versions }}
27+
name: PHP ${{ matrix.php }}
2828

2929
steps:
3030
- name: Checkout
@@ -33,7 +33,7 @@ jobs:
3333
- name: Setup PHP
3434
uses: shivammathur/setup-php@v2
3535
with:
36-
php: ${{ matrix.php-versions }}
36+
php: ${{ matrix.php }}
3737
coverage: ${{ matrix.coverage }}
3838
extensions: json, mbstring
3939

composer.json

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,47 @@
11
{
2-
"name": "osiset/basic-shopify-api",
3-
"type": "library",
4-
"description": "A basic Shopify API wrapper with REST and GraphQL support, powered by Guzzle.",
5-
"keywords": [
6-
"api",
7-
"shopify",
8-
"rest",
9-
"graphql"
10-
],
11-
"license": "MIT",
12-
"authors": [
13-
{
14-
"name": "Tyler King",
15-
"email": "tyler@osiset.com"
2+
"name": "osiset/basic-shopify-api",
3+
"type": "library",
4+
"description": "A basic Shopify API wrapper with REST and GraphQL support, powered by Guzzle.",
5+
"keywords": [
6+
"api",
7+
"graphql",
8+
"rest",
9+
"shopify",
10+
"wrapper"
11+
],
12+
"license": "MIT",
13+
"authors": [
14+
{
15+
"name": "Tyler King",
16+
"email": "tyler@osiset.com"
17+
}
18+
],
19+
"require": {
20+
"php": ">=7.3.0",
21+
"ext-json": "*",
22+
"caseyamcl/guzzle_retry_middleware": "^2.3",
23+
"guzzlehttp/guzzle": "^6.5 || ^7.0"
24+
},
25+
"require-dev": {
26+
"ergebnis/composer-normalize": "^2.8",
27+
"phpstan/phpstan": "^0.12",
28+
"phpunit/phpunit": "^6.2 || ^9.3"
29+
},
30+
"config": {
31+
"sort-packages": true
32+
},
33+
"autoload": {
34+
"psr-4": {
35+
"Osiset\\BasicShopifyAPI\\": "src/"
36+
}
37+
},
38+
"autoload-dev": {
39+
"psr-4": {
40+
"Osiset\\BasicShopifyAPI\\Test\\": "test/"
41+
}
42+
},
43+
"support": {
44+
"issues": "https://github.com/osiset/basic-shopify-api/issues",
45+
"source": "https://github.com/osiset/basic-shopify-api"
1646
}
17-
],
18-
"require": {
19-
"php": ">=7.2.0",
20-
"caseyamcl/guzzle_retry_middleware": "^2.3",
21-
"guzzlehttp/guzzle": "^6.5 || ^7.0"
22-
},
23-
"require-dev": {
24-
"ergebnis/composer-normalize": "^2.8",
25-
"phpstan/phpstan": "^0.12",
26-
"phpunit/phpunit": "^6.2 || ^9.3"
27-
},
28-
"autoload": {
29-
"psr-4": {
30-
"Osiset\\BasicShopifyAPI\\": "src/"
31-
}
32-
},
33-
"autoload-dev": {
34-
"psr-4": {
35-
"Osiset\\BasicShopifyAPI\\Test\\": "test/"
36-
}
37-
},
38-
"scripts": {
39-
"test": "bin/phpunit"
40-
}
4147
}

src/Clients/Rest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected function extractLinkHeader(string $header): ResponseAccess
2929

3030
foreach (array_keys($links) as $type) {
3131
preg_match(str_replace('{type}', $type, $regex), $header, $matches);
32-
$links[$type] = isset($matches[1]) ? $matches[1] : null;
32+
$links[$type] = $matches[1] ?? null;
3333
}
3434

3535
return new ResponseAccess($links);

src/Middleware/RateLimiting.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected function handleGraph(BasicShopifyAPI $api): bool
9393
// Get current, last request time, and time difference
9494
$currentTime = $td->getCurrentTime();
9595
$lastTime = $ts->get($api->getSession());
96-
$lastTime = isset($lastTime[0]) ? $lastTime[0] : 0;
96+
$lastTime = $lastTime[0] ?? 0;
9797

9898
// Get the last request cost
9999
/** @var int $lastCost */

src/ResponseAccess.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,6 @@ public function getErrors()
262262
return;
263263
}
264264

265-
return isset($this->container['errors']) ? $this->container['errors'] : $this->container['error'];
265+
return $this->container['errors'] ?? $this->container['error'];
266266
}
267267
}

src/Store/Memory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function get(Session $session): array
3333
{
3434
$shop = $session->getShop();
3535

36-
return isset($this->container[$shop]) ? $this->container[$shop] : [];
36+
return $this->container[$shop] ?? [];
3737
}
3838

3939
/**

test/BasicShopifyAPITest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public function testSetClient(): void
1919
$client = new Client();
2020
$api->setClient($client);
2121

22-
$this->assertEquals($client, $api->getClient());
23-
$this->assertEquals($client, $api->getGraphClient()->getClient());
24-
$this->assertEquals($client, $api->getRestClient()->getClient());
22+
$this->assertSame($client, $api->getClient());
23+
$this->assertSame($client, $api->getGraphClient()->getClient());
24+
$this->assertSame($client, $api->getRestClient()->getClient());
2525
}
2626

2727
public function testSetAndGetOptions(): void
@@ -34,7 +34,7 @@ public function testSetAndGetOptions(): void
3434
$opts->setType(false);
3535
$api->setOptions($opts);
3636

37-
$this->assertEquals($opts, $api->getOptions());
37+
$this->assertSame($opts, $api->getOptions());
3838
}
3939

4040
public function testSetAndGetSession(): void
@@ -46,7 +46,7 @@ public function testSetAndGetSession(): void
4646
$session = new Session('example.myshopify.com', 'abc123');
4747
$api->setSession($session);
4848

49-
$this->assertEquals($session, $api->getSession());
49+
$this->assertSame($session, $api->getSession());
5050
}
5151

5252
public function testWithSession(): void

test/Clients/RestTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testExtractLinkHeader(): void
6161
// Run the request
6262
$result = $api->getRestClient()->request('GET', '/admin/shop.json');
6363

64-
$this->assertEquals($pageInfo, $result['link']['next']);
64+
$this->assertSame($pageInfo, $result['link']['next']);
6565
}
6666

6767
public function testRequestAccess(): void
@@ -138,7 +138,7 @@ public function testGetAuthUrlForOffline(): void
138138
});
139139
$api->setSession(new Session('example.myshopify.com'));
140140

141-
$this->assertEquals(
141+
$this->assertSame(
142142
'https://example.myshopify.com/admin/oauth/authorize?client_id=123&scope=read_products%2Cwrite_products&redirect_uri=https%3A%2F%2Flocalapp.local%2F',
143143
$api->getAuthUrl(['read_products', 'write_products'], 'https://localapp.local/')
144144
);
@@ -152,7 +152,7 @@ public function testGetAuthUrlForPerUser(): void
152152
});
153153
$api->setSession(new Session('example.myshopify.com'));
154154

155-
$this->assertEquals(
155+
$this->assertSame(
156156
'https://example.myshopify.com/admin/oauth/authorize?client_id=123&scope=read_products%2Cwrite_products&redirect_uri=https%3A%2F%2Flocalapp.local%2F&grant_options%5B%5D=per-user',
157157
$api->getAuthUrl(['read_products', 'write_products'], 'https://localapp.local/', 'per-user')
158158
);
@@ -196,7 +196,7 @@ public function testRequestSuccess(): void
196196
$this->assertInstanceOf(ResponseAccess::class, $response['body']);
197197
$this->assertSame('limit=1&page=1', $query);
198198
$this->assertSame('!#@', $tokenHeader);
199-
$this->assertEquals(true, $specialHeader);
199+
$this->assertSame('1', $specialHeader);
200200
}
201201

202202
public function testRequestForceRequestType(): void

test/Middleware/AuthRequestTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function testRestVersioningOfApiPath(): void
2121
$callMw = call_user_func(
2222
$this->buildMw($opts),
2323
function (RequestInterface $request, array $options): void {
24-
$this->assertEquals(
24+
$this->assertSame(
2525
'/admin/api/2020-01/shop.json',
2626
(string) $request->getUri()
2727
);
@@ -40,7 +40,7 @@ public function testGraphVersioningOfApiPath(): void
4040
$callMw = call_user_func(
4141
$this->buildMw($opts),
4242
function (RequestInterface $request, array $options): void {
43-
$this->assertEquals(
43+
$this->assertSame(
4444
'/admin/api/2020-01/graphql.json',
4545
(string) $request->getUri()
4646
);
@@ -59,7 +59,7 @@ public function testRestNotVersioningApiPath(): void
5959
$callMw = call_user_func(
6060
$this->buildMw($opts),
6161
function (RequestInterface $request, array $options): void {
62-
$this->assertEquals(
62+
$this->assertSame(
6363
'/admin/api/2019-04/shop.json',
6464
(string) $request->getUri()
6565
);
@@ -78,7 +78,7 @@ public function testGraphNotVersioningApiPath(): void
7878
$callMw = call_user_func(
7979
$this->buildMw($opts),
8080
function (RequestInterface $request, array $options): void {
81-
$this->assertEquals(
81+
$this->assertSame(
8282
'/admin/api/2019-04/graphql.json',
8383
(string) $request->getUri()
8484
);

test/Middleware/UpdateRequestTimeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function testRuns(): void
2020
$mw = new UpdateRequestTime($api);
2121

2222
// Ensure its empty
23-
$this->assertEquals(
23+
$this->assertSame(
2424
[],
2525
$api->getRestClient()->getTimeStore()->get($api->getSession())
2626
);

0 commit comments

Comments
 (0)