Compare commits
No commits in common. "main" and "899b034013c89f13ecd5d2e444be2ab026326242" have entirely different histories.
main
...
899b034013
@ -1,12 +1,8 @@
|
||||
{
|
||||
"com.thorlaksson.phpcs.formatOnSave" : true,
|
||||
"com.thorlaksson.phpcs.runOnChange" : "onSave",
|
||||
"com.thorlaksson.phpcs.standard" : "phpcs.xml",
|
||||
"editor.default_syntax" : "php",
|
||||
"php.validate" : "onSave",
|
||||
"prettier.format-on-save" : "Disable",
|
||||
"prettier.format-on-save.ignore-remote" : "Disable",
|
||||
"prettier.format-on-save.ignore-without-config" : "Disable",
|
||||
"workspace.color" : 1,
|
||||
"workspace.name" : "APnutI"
|
||||
}
|
||||
|
@ -18,10 +18,10 @@
|
||||
<property name="eolChar" value="\n"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<arg name="tab-width" value="4"/>
|
||||
<arg name="tab-width" value="2"/>
|
||||
<rule ref="Generic.WhiteSpace.ScopeIndent">
|
||||
<properties>
|
||||
<property name="indent" value="4"/>
|
||||
<property name="indent" value="2"/>
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
|
1570
src/APnutI.php
1570
src/APnutI.php
File diff suppressed because it is too large
Load Diff
74
src/Meta.php
74
src/Meta.php
@ -9,43 +9,43 @@ use APnutI\Exceptions\HttpPnutForbiddenException;
|
||||
|
||||
class Meta
|
||||
{
|
||||
public bool $more = false;
|
||||
public ?int $max_id = null;
|
||||
public ?int $min_id = null;
|
||||
public ?int $code = -1;
|
||||
public bool $more = false;
|
||||
public ?int $max_id = null;
|
||||
public ?int $min_id = null;
|
||||
public ?int $code = -1;
|
||||
|
||||
public function __construct(array $json)
|
||||
{
|
||||
if (empty($json['meta'])) {
|
||||
return;
|
||||
}
|
||||
$meta = (array)$json['meta'];
|
||||
if (!empty($meta['more'])) {
|
||||
$this->more = (bool)$meta['more'];
|
||||
}
|
||||
if (!empty($meta['max_id'])) {
|
||||
$this->max_id = (int)$meta['max_id'];
|
||||
}
|
||||
if (!empty($meta['min_id'])) {
|
||||
$this->min_id = (int)$meta['min_id'];
|
||||
}
|
||||
if (!empty($meta['code'])) {
|
||||
$this->code = $meta['code'];
|
||||
if ($this->code === 400) {
|
||||
throw new PnutException($meta['error_message']);
|
||||
}
|
||||
if ($this->code === 401) {
|
||||
throw new NotAuthorizedException($meta['error_message']);
|
||||
}
|
||||
if ($this->code === 403) {
|
||||
throw new HttpPnutForbiddenException();
|
||||
}
|
||||
if ($this->code === 404) {
|
||||
throw new NotFoundException();
|
||||
}
|
||||
if ($meta['code'] < 200 || $meta['code'] >= 300) {
|
||||
throw new PnutException($meta['error_message']);
|
||||
}
|
||||
}
|
||||
public function __construct(array $json)
|
||||
{
|
||||
if (empty($json['meta'])) {
|
||||
return;
|
||||
}
|
||||
$meta = (array)$json['meta'];
|
||||
if (!empty($meta['more'])) {
|
||||
$this->more = (bool)$meta['more'];
|
||||
}
|
||||
if (!empty($meta['max_id'])) {
|
||||
$this->max_id = (int)$meta['max_id'];
|
||||
}
|
||||
if (!empty($meta['min_id'])) {
|
||||
$this->min_id = (int)$meta['min_id'];
|
||||
}
|
||||
if (!empty($meta['code'])) {
|
||||
$this->code = $meta['code'];
|
||||
if ($this->code === 400) {
|
||||
throw new PnutException($meta['error_message']);
|
||||
}
|
||||
if ($this->code === 401) {
|
||||
throw new NotAuthorizedException($meta['error_message']);
|
||||
}
|
||||
if ($this->code === 403) {
|
||||
throw new HttpPnutForbiddenException();
|
||||
}
|
||||
if ($this->code === 404) {
|
||||
throw new NotFoundException();
|
||||
}
|
||||
if ($meta['code'] < 200 || $meta['code'] >= 300) {
|
||||
throw new PnutException($meta['error_message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user