Skip to content

Commit

Permalink
fix psalm errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Baptouuuu committed Oct 19, 2024
1 parent 7c43f93 commit ef810a2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/Authority/Port.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ public function format(): string

public function value(): int
{
return $this->value ?: 0;
return match ($this->value) {
null => 0,
default => $this->value,
};
}

public function toString(): string
Expand Down
40 changes: 32 additions & 8 deletions src/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,42 @@ public static function of(string $string): self
}

return new self(
$data['scheme'] ? Scheme::of($data['scheme']) : Scheme::none(),
match ($data['scheme']) {
null, '' => Scheme::none(),
default => Scheme::of($data['scheme']),
},
Authority::of(
UserInformation::of(
$data['user'] ? User::of($data['user']) : User::none(),
$data['pass'] ? Password::of($data['pass']) : Password::none(),
match ($data['user']) {
null, '' => User::none(),
default => User::of($data['user']),
},
match ($data['pass']) {
null, '' => Password::none(),
default => Password::of($data['pass']),
},
),
$data['host'] ? Host::of($data['host']) : Host::none(),
$data['port'] ? Port::of((int) $data['port']) : Port::none(),
match ($data['host']) {
null, '' => Host::none(),
default => Host::of($data['host']),
},
match ($data['port']) {
null, '' => Port::none(),
default => Port::of((int) $data['port']),
},
),
$data['path'] && !empty($data['path']) ? Path::of($data['path']) : Path::none(),
$data['query'] ? Query::of($data['query']) : Query::none(),
$data['fragment'] ? Fragment::of($data['fragment']) : Fragment::none(),
match ($data['path']) {
null, '' => Path::none(),
default => Path::of($data['path']),
},
match ($data['query']) {
null, '' => Query::none(),
default => Query::of($data['query']),
},
match ($data['fragment']) {
null, '' => Fragment::none(),
default => Fragment::of($data['fragment']),
},
);
}

Expand Down

0 comments on commit ef810a2

Please sign in to comment.