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.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"
}

View File

@ -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>

File diff suppressed because it is too large Load Diff

View File

@ -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']);
}
}
}
}