Skip to content

Commit ef810a2

Browse files
committed
fix psalm errors
1 parent 7c43f93 commit ef810a2

File tree

2 files changed

+36
-9
lines changed

2 files changed

+36
-9
lines changed

src/Authority/Port.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ public function format(): string
5353

5454
public function value(): int
5555
{
56-
return $this->value ?: 0;
56+
return match ($this->value) {
57+
null => 0,
58+
default => $this->value,
59+
};
5760
}
5861

5962
public function toString(): string

src/Url.php

+32-8
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,42 @@ public static function of(string $string): self
5555
}
5656

5757
return new self(
58-
$data['scheme'] ? Scheme::of($data['scheme']) : Scheme::none(),
58+
match ($data['scheme']) {
59+
null, '' => Scheme::none(),
60+
default => Scheme::of($data['scheme']),
61+
},
5962
Authority::of(
6063
UserInformation::of(
61-
$data['user'] ? User::of($data['user']) : User::none(),
62-
$data['pass'] ? Password::of($data['pass']) : Password::none(),
64+
match ($data['user']) {
65+
null, '' => User::none(),
66+
default => User::of($data['user']),
67+
},
68+
match ($data['pass']) {
69+
null, '' => Password::none(),
70+
default => Password::of($data['pass']),
71+
},
6372
),
64-
$data['host'] ? Host::of($data['host']) : Host::none(),
65-
$data['port'] ? Port::of((int) $data['port']) : Port::none(),
73+
match ($data['host']) {
74+
null, '' => Host::none(),
75+
default => Host::of($data['host']),
76+
},
77+
match ($data['port']) {
78+
null, '' => Port::none(),
79+
default => Port::of((int) $data['port']),
80+
},
6681
),
67-
$data['path'] && !empty($data['path']) ? Path::of($data['path']) : Path::none(),
68-
$data['query'] ? Query::of($data['query']) : Query::none(),
69-
$data['fragment'] ? Fragment::of($data['fragment']) : Fragment::none(),
82+
match ($data['path']) {
83+
null, '' => Path::none(),
84+
default => Path::of($data['path']),
85+
},
86+
match ($data['query']) {
87+
null, '' => Query::none(),
88+
default => Query::of($data['query']),
89+
},
90+
match ($data['fragment']) {
91+
null, '' => Fragment::none(),
92+
default => Fragment::of($data['fragment']),
93+
},
7094
);
7195
}
7296

0 commit comments

Comments
 (0)