Compare commits

..

No commits in common. "2f5aa63306ed989499a2f2003d8cfcc36061d341" and "899b034013c89f13ecd5d2e444be2ab026326242" have entirely different histories.

4 changed files with 793 additions and 859 deletions

View File

@ -1,12 +1,8 @@
{ {
"com.thorlaksson.phpcs.formatOnSave" : true,
"com.thorlaksson.phpcs.runOnChange" : "onSave", "com.thorlaksson.phpcs.runOnChange" : "onSave",
"com.thorlaksson.phpcs.standard" : "phpcs.xml", "com.thorlaksson.phpcs.standard" : "phpcs.xml",
"editor.default_syntax" : "php", "editor.default_syntax" : "php",
"php.validate" : "onSave", "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.color" : 1,
"workspace.name" : "APnutI" "workspace.name" : "APnutI"
} }

View File

@ -18,10 +18,10 @@
<property name="eolChar" value="\n"/> <property name="eolChar" value="\n"/>
</properties> </properties>
</rule> </rule>
<arg name="tab-width" value="4"/> <arg name="tab-width" value="2"/>
<rule ref="Generic.WhiteSpace.ScopeIndent"> <rule ref="Generic.WhiteSpace.ScopeIndent">
<properties> <properties>
<property name="indent" value="4"/> <property name="indent" value="2"/>
</properties> </properties>
</rule> </rule>

File diff suppressed because it is too large Load Diff

View File

@ -9,43 +9,43 @@ use APnutI\Exceptions\HttpPnutForbiddenException;
class Meta class Meta
{ {
public bool $more = false; public bool $more = false;
public ?int $max_id = null; public ?int $max_id = null;
public ?int $min_id = null; public ?int $min_id = null;
public ?int $code = -1; public ?int $code = -1;
public function __construct(array $json) public function __construct(array $json)
{ {
if (empty($json['meta'])) { if (empty($json['meta'])) {
return; 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']);
}
}
} }
$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']);
}
}
}
} }