Skip to content

Commit 79a4030

Browse files
committed
normalize
1 parent 85827f7 commit 79a4030

File tree

10 files changed

+66
-58
lines changed

10 files changed

+66
-58
lines changed

src/Facades/WordPress.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212
use Storipress\WordPress\Requests\User;
1313

1414
/**
15+
* @method static GeneralRequest request()
16+
* @method static User user()
1517
* @method static Post post()
1618
* @method static Category category()
1719
* @method static Tag tag()
18-
* @method static User user()
19-
* @method static GeneralRequest request()
20-
* @method static \Storipress\WordPress\WordPress setSite(string $site)
20+
* @method static \Storipress\WordPress\WordPress instance()
2121
* @method static \Storipress\WordPress\WordPress site()
22-
* @method static \Storipress\WordPress\WordPress setUsername(string $username)
22+
* @method static \Storipress\WordPress\WordPress setSite(string $site)
2323
* @method static \Storipress\WordPress\WordPress username()
24-
* @method static \Storipress\WordPress\WordPress setApplicationKey(string $key)
25-
* @method static \Storipress\WordPress\WordPress applicationKey()
26-
* @method static \Storipress\WordPress\WordPress instance()
24+
* @method static \Storipress\WordPress\WordPress setUsername(string $username)
25+
* @method static \Storipress\WordPress\WordPress password()
26+
* @method static \Storipress\WordPress\WordPress setPassword(string $password)
2727
*/
2828
class WordPress extends Facade
2929
{

src/Objects/Post.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Post extends WordPressObject
1414

1515
public string $date_gmt;
1616

17-
public RenderObject $guid;
17+
public Render $guid;
1818

1919
public string $modified;
2020

@@ -30,11 +30,11 @@ class Post extends WordPressObject
3030

3131
public string $link;
3232

33-
public RenderObject $title;
33+
public Render $title;
3434

35-
public RenderObject $content;
35+
public Render $content;
3636

37-
public RenderObject $excerpt;
37+
public Render $excerpt;
3838

3939
public int $author;
4040

@@ -64,13 +64,13 @@ class Post extends WordPressObject
6464

6565
public static function from(stdClass $data): static
6666
{
67-
$data->guid = RenderObject::from($data->guid);
67+
$data->guid = Render::from($data->guid);
6868

69-
$data->title = RenderObject::from($data->title);
69+
$data->title = Render::from($data->title);
7070

71-
$data->content = RenderObject::from($data->content);
71+
$data->content = Render::from($data->content);
7272

73-
$data->excerpt = RenderObject::from($data->excerpt);
73+
$data->excerpt = Render::from($data->excerpt);
7474

7575
return parent::from($data);
7676
}

src/Objects/RenderObject.php renamed to src/Objects/Render.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Storipress\WordPress\Objects;
46

5-
class RenderObject extends WordPressObject
7+
class Render extends WordPressObject
68
{
79
public ?string $raw;
810

src/Requests/Category.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Category extends Request
1313
/**
1414
* https://developer.wordpress.org/rest-api/reference/categories/#list-categories
1515
*
16-
* @return CategoryObject[]
16+
* @return array<int, CategoryObject>
1717
*
1818
* @throws HttpException
1919
* @throws UnexpectedValueException

src/Requests/GeneralRequest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Storipress\WordPress\Requests;
46

57
use stdClass;
@@ -9,7 +11,7 @@ class GeneralRequest extends Request
911
/**
1012
* @param non-empty-string $path
1113
* @param array<mixed> $arguments
12-
* @return stdClass|stdClass[]
14+
* @return stdClass|array<int, stdClass>
1315
*
1416
* @throws \Storipress\WordPress\Exceptions\HttpException
1517
* @throws \Storipress\WordPress\Exceptions\UnexpectedValueException
@@ -22,7 +24,7 @@ public function get(string $path, array $arguments): stdClass|array
2224
/**
2325
* @param non-empty-string $path
2426
* @param array<mixed> $arguments
25-
* @return stdClass|stdClass[]
27+
* @return stdClass|array<int, stdClass>
2628
*
2729
* @throws \Storipress\WordPress\Exceptions\HttpException
2830
* @throws \Storipress\WordPress\Exceptions\UnexpectedValueException
@@ -35,7 +37,7 @@ public function post(string $path, array $arguments): stdClass|array
3537
/**
3638
* @param non-empty-string $path
3739
* @param array<mixed> $arguments
38-
* @return stdClass|stdClass[]
40+
* @return stdClass|array<int, stdClass>
3941
*
4042
* @throws \Storipress\WordPress\Exceptions\HttpException
4143
* @throws \Storipress\WordPress\Exceptions\UnexpectedValueException

src/Requests/Post.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Post extends Request
1313
/**
1414
* https://developer.wordpress.org/rest-api/reference/posts/#list-posts
1515
*
16-
* @return PostObject[]
16+
* @return array<int, PostObject>
1717
*
1818
* @throws HttpException
1919
* @throws UnexpectedValueException

src/Requests/Request.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Storipress\WordPress\Requests;
46

57
use Illuminate\Http\Client\Response;
@@ -24,7 +26,7 @@ public function __construct(
2426
* @param 'get'|'post'|'patch'|'delete' $method
2527
* @param non-empty-string $path
2628
* @param array<mixed> $options
27-
* @return ($method is 'delete' ? bool : stdClass|stdClass[])
29+
* @return ($method is 'delete' ? bool : stdClass|array<int, stdClass>)
2830
*
2931
* @throws UnexpectedValueException
3032
* @throws HttpException
@@ -37,7 +39,7 @@ protected function request(
3739
$response = $this
3840
->app
3941
->http
40-
->withBasicAuth($this->app->username(), $this->app->applicationKey())
42+
->withBasicAuth($this->app->username(), $this->app->password())
4143
->{$method}($this->getUrl($path), $options);
4244

4345
if (!($response instanceof Response)) {

src/Requests/Tag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Tag extends Request
1313
/**
1414
* https://developer.wordpress.org/rest-api/reference/tags/#list-tags
1515
*
16-
* @return TagObject[]
16+
* @return array<int, TagObject>
1717
*
1818
* @throws HttpException
1919
* @throws UnexpectedValueException

src/Requests/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class User extends Request
1313
/**
1414
* https://developer.wordpress.org/rest-api/reference/users/#list-users
1515
*
16-
* @return UserObject[]
16+
* @return array<int, UserObject>
1717
*
1818
* @throws HttpException
1919
* @throws UnexpectedValueException

src/WordPress.php

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Storipress\WordPress;
46

57
use Illuminate\Http\Client\Factory;
@@ -11,75 +13,85 @@
1113

1214
class WordPress
1315
{
14-
protected readonly Post $post;
16+
protected readonly GeneralRequest $request;
1517

16-
protected readonly Tag $tag;
18+
protected readonly User $user;
1719

18-
protected readonly Category $category;
20+
protected readonly Post $post;
1921

20-
protected readonly User $user;
22+
protected readonly Category $category;
2123

22-
protected readonly GeneralRequest $request;
24+
protected readonly Tag $tag;
2325

2426
protected string $site;
2527

2628
protected string $username;
2729

28-
protected string $applicationKey;
30+
protected string $password;
2931

3032
public function __construct(
3133
public Factory $http,
3234
) {
33-
$this->post = new Post($this);
35+
$this->request = new GeneralRequest($this);
3436

35-
$this->tag = new Tag($this);
37+
$this->user = new User($this);
3638

37-
$this->category = new Category($this);
39+
$this->post = new Post($this);
3840

39-
$this->user = new User($this);
41+
$this->category = new Category($this);
4042

41-
$this->request = new GeneralRequest($this);
43+
$this->tag = new Tag($this);
4244
}
4345

4446
public function instance(): static
4547
{
4648
return $this;
4749
}
4850

49-
public function setApplicationKey(string $key): static
51+
public function site(): string
52+
{
53+
return $this->site;
54+
}
55+
56+
public function setSite(string $site): static
5057
{
51-
$this->applicationKey = $key;
58+
$this->site = $site;
5259

5360
return $this;
5461
}
5562

56-
public function applicationKey(): string
63+
public function username(): string
5764
{
58-
return $this->applicationKey;
65+
return $this->username;
5966
}
6067

61-
public function setSite(string $site): static
68+
public function setUsername(string $username): static
6269
{
63-
$this->site = $site;
70+
$this->username = $username;
6471

6572
return $this;
6673
}
6774

68-
public function site(): string
75+
public function password(): string
6976
{
70-
return $this->site;
77+
return $this->password;
7178
}
7279

73-
public function setUsername(string $username): static
80+
public function setPassword(string $key): static
7481
{
75-
$this->username = $username;
82+
$this->password = $key;
7683

7784
return $this;
7885
}
7986

80-
public function username(): string
87+
public function request(): GeneralRequest
8188
{
82-
return $this->username;
89+
return $this->request;
90+
}
91+
92+
public function user(): User
93+
{
94+
return $this->user;
8395
}
8496

8597
public function post(): Post
@@ -96,14 +108,4 @@ public function tag(): Tag
96108
{
97109
return $this->tag;
98110
}
99-
100-
public function user(): User
101-
{
102-
return $this->user;
103-
}
104-
105-
public function request(): GeneralRequest
106-
{
107-
return $this->request;
108-
}
109111
}

0 commit comments

Comments
 (0)