Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<UndefinedAttributeClass errorLevel="suppress" />
</issueHandlers>
</psalm>
2 changes: 2 additions & 0 deletions src/EnvironmentPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ private function __construct(
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function of(string $value): self
{
return new self($value);
}

#[\NoDiscard]
public function toString(): string
{
return $this->value;
Expand Down
9 changes: 9 additions & 0 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ private function __construct(
) {
}

#[\NoDiscard]
public static function osx(
Clock $clock,
Control $control,
Expand All @@ -35,13 +36,15 @@ public static function osx(
return new self(OSX::of($clock, $control, $path));
}

#[\NoDiscard]
public static function linux(
Clock $clock,
Control $control,
): self {
return new self(Linux::of($clock, $control));
}

#[\NoDiscard]
public static function logger(self $server, LoggerInterface $logger): self
{
return new self(Logger::of(
Expand All @@ -53,6 +56,7 @@ public static function logger(self $server, LoggerInterface $logger): self
/**
* @return Attempt<Cpu>
*/
#[\NoDiscard]
public function cpu(): Attempt
{
return $this->implementation->cpu();
Expand All @@ -61,11 +65,13 @@ public function cpu(): Attempt
/**
* @return Attempt<Memory>
*/
#[\NoDiscard]
public function memory(): Attempt
{
return $this->implementation->memory();
}

#[\NoDiscard]
public function processes(): Processes
{
return $this->implementation->processes();
Expand All @@ -74,16 +80,19 @@ public function processes(): Processes
/**
* @return Attempt<LoadAverage>
*/
#[\NoDiscard]
public function loadAverage(): Attempt
{
return $this->implementation->loadAverage();
}

#[\NoDiscard]
public function disk(): Disk
{
return $this->implementation->disk();
}

#[\NoDiscard]
public function tmp(): Path
{
return Path::of(\rtrim(\sys_get_temp_dir(), '/').'/');
Expand Down
5 changes: 5 additions & 0 deletions src/Server/Cpu.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,31 @@ public static function of(
return new self($user, $system, $idle, $cores);
}

#[\NoDiscard]
public function user(): Percentage
{
return $this->user;
}

#[\NoDiscard]
public function system(): Percentage
{
return $this->system;
}

#[\NoDiscard]
public function idle(): Percentage
{
return $this->idle;
}

#[\NoDiscard]
public function cores(): Cores
{
return $this->cores;
}

#[\NoDiscard]
public function toString(): string
{
return \sprintf(
Expand Down
2 changes: 2 additions & 0 deletions src/Server/Cpu/Cores.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ public static function of(int $value): self
/**
* @return int<1, max>
*/
#[\NoDiscard]
public function toInt(): int
{
return $this->value;
}

#[\NoDiscard]
public function toString(): string
{
return (string) $this->value;
Expand Down
2 changes: 2 additions & 0 deletions src/Server/Cpu/Percentage.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ public static function maybe(float $value): Maybe
return Maybe::just(new self($value));
}

#[\NoDiscard]
public function toFloat(): float
{
return $this->value;
}

#[\NoDiscard]
public function toString(): string
{
return \sprintf(
Expand Down
2 changes: 2 additions & 0 deletions src/Server/Disk.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public static function logger(self $disk, LoggerInterface $logger): self
/**
* @return Sequence<Volume>
*/
#[\NoDiscard]
public function volumes(): Sequence
{
return $this->implementation->volumes();
Expand All @@ -54,6 +55,7 @@ public function volumes(): Sequence
/**
* @return Maybe<Volume>
*/
#[\NoDiscard]
public function get(MountPoint $point): Maybe
{
return $this->implementation->get($point);
Expand Down
5 changes: 5 additions & 0 deletions src/Server/Disk/Volume.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,31 @@ public static function of(
return new self($mountPoint, $size, $available, $used, $usage);
}

#[\NoDiscard]
public function mountPoint(): MountPoint
{
return $this->mountPoint;
}

#[\NoDiscard]
public function size(): Bytes
{
return $this->size;
}

#[\NoDiscard]
public function available(): Bytes
{
return $this->available;
}

#[\NoDiscard]
public function used(): Bytes
{
return $this->used;
}

#[\NoDiscard]
public function usage(): Usage
{
return $this->usage;
Expand Down
3 changes: 3 additions & 0 deletions src/Server/Disk/Volume/MountPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ public static function of(string $value): self
return new self($value);
}

#[\NoDiscard]
public function equals(self $point): bool
{
return $point->is($this->value);
}

#[\NoDiscard]
public function is(string $point): bool
{
return $this->value === $point;
Expand All @@ -40,6 +42,7 @@ public function is(string $point): bool
/**
* @return non-empty-string
*/
#[\NoDiscard]
public function toString(): string
{
return $this->value;
Expand Down
2 changes: 2 additions & 0 deletions src/Server/Disk/Volume/Usage.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ public static function maybe(float $value): Maybe
return Maybe::just(new self($value));
}

#[\NoDiscard]
public function toFloat(): float
{
return $this->value;
}

#[\NoDiscard]
public function toString(): string
{
return \sprintf(
Expand Down
3 changes: 3 additions & 0 deletions src/Server/LoadAverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,19 @@ public static function maybe(
return Maybe::just(new self($lastMinute, $lastFiveMinutes, $lastFifteenMinutes));
}

#[\NoDiscard]
public function lastMinute(): float
{
return $this->lastMinute;
}

#[\NoDiscard]
public function lastFiveMinutes(): float
{
return $this->lastFiveMinutes;
}

#[\NoDiscard]
public function lastFifteenMinutes(): float
{
return $this->lastFifteenMinutes;
Expand Down
5 changes: 5 additions & 0 deletions src/Server/Memory.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,31 @@ public static function of(
return new self($total, $active, $free, $swap, $used);
}

#[\NoDiscard]
public function total(): Bytes
{
return $this->total;
}

#[\NoDiscard]
public function active(): Bytes
{
return $this->active;
}

#[\NoDiscard]
public function free(): Bytes
{
return $this->free;
}

#[\NoDiscard]
public function swap(): Bytes
{
return $this->swap;
}

#[\NoDiscard]
public function used(): Bytes
{
return $this->used;
Expand Down
2 changes: 2 additions & 0 deletions src/Server/Memory/Bytes.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ public static function of(int $value): self
/**
* @return int<0, max>
*/
#[\NoDiscard]
public function toInt(): int
{
return $this->value;
}

#[\NoDiscard]
public function toString(): string
{
return Size::of($this->value)->toString();
Expand Down
6 changes: 6 additions & 0 deletions src/Server/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,25 @@ public static function of(
return new self($pid, $user, $cpu, $memory, $start, $command);
}

#[\NoDiscard]
public function pid(): Pid
{
return $this->pid;
}

#[\NoDiscard]
public function user(): User
{
return $this->user;
}

#[\NoDiscard]
public function cpu(): Percentage
{
return $this->cpu;
}

#[\NoDiscard]
public function memory(): Memory
{
return $this->memory;
Expand All @@ -71,11 +75,13 @@ public function memory(): Memory
/**
* @return Maybe<Point>
*/
#[\NoDiscard]
public function start(): Maybe
{
return $this->start;
}

#[\NoDiscard]
public function command(): Command
{
return $this->command;
Expand Down
2 changes: 2 additions & 0 deletions src/Server/Process/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static function of(string $value): self
return new self($value);
}

#[\NoDiscard]
public function matches(RegExp $pattern): bool
{
return $pattern->matches(Str::of($this->value));
Expand All @@ -40,6 +41,7 @@ public function matches(RegExp $pattern): bool
/**
* @return non-empty-string
*/
#[\NoDiscard]
public function toString(): string
{
return $this->value;
Expand Down
2 changes: 2 additions & 0 deletions src/Server/Process/Memory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ public static function maybe(float $value): Maybe
return Maybe::just(new self($value));
}

#[\NoDiscard]
public function toFloat(): float
{
return $this->value;
}

#[\NoDiscard]
public function toString(): string
{
return \sprintf(
Expand Down
4 changes: 4 additions & 0 deletions src/Server/Process/Pid.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ public static function of(int $value): self
return new self($value);
}

#[\NoDiscard]
public function equals(self $pid): bool
{
return $pid->is($this->value);
}

#[\NoDiscard]
public function is(int $value): bool
{
return $this->value === $value;
Expand All @@ -40,11 +42,13 @@ public function is(int $value): bool
/**
* @return int<1, max>
*/
#[\NoDiscard]
public function toInt(): int
{
return $this->value;
}

#[\NoDiscard]
public function toString(): string
{
return (string) $this->value;
Expand Down
Loading