Compare commits

..

3 Commits

Author SHA1 Message Date
2f5aa63306
formatting 2024-04-10 11:52:35 +02:00
7f16b67d02
fix regex 2024-04-10 11:34:54 +02:00
4a3bbeec79
formatting 2024-04-10 11:33:44 +02:00
4 changed files with 853 additions and 787 deletions

View File

@ -1,8 +1,12 @@
{
"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="2"/>
<arg name="tab-width" value="4"/>
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="2"/>
<property name="indent" value="4"/>
</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;
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']);
}
}
}
$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']);
}
}
}
}