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>
3 changes: 3 additions & 0 deletions src/Crontab.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ private function __construct(Command $command, Job ...$jobs)
/**
* @return Attempt<SideEffect>
*/
#[\NoDiscard]
public function __invoke(Server $server): Attempt
{
$installOn = Script::of($this->command);
Expand All @@ -52,6 +53,7 @@ public function __invoke(Server $server): Attempt
* @no-named-arguments
* @psalm-pure
*/
#[\NoDiscard]
public static function forConnectedUser(Job ...$jobs): self
{
return new self(Command::foreground('crontab'), ...$jobs);
Expand All @@ -63,6 +65,7 @@ public static function forConnectedUser(Job ...$jobs): self
*
* @param non-empty-string $user
*/
#[\NoDiscard]
public static function forUser(string $user, Job ...$jobs): self
{
return new self(
Expand Down
4 changes: 4 additions & 0 deletions src/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function __construct(Schedule $schedule, Command $command)
*
* @throws \DomainException
*/
#[\NoDiscard]
public static function of(string $value): self
{
return self::attempt($value)->unwrap();
Expand All @@ -42,6 +43,7 @@ public static function of(string $value): self
*
* @return Maybe<self>
*/
#[\NoDiscard]
public static function maybe(string $value): Maybe
{
return self::attempt($value)->maybe();
Expand All @@ -52,6 +54,7 @@ public static function maybe(string $value): Maybe
*
* @return Attempt<self>
*/
#[\NoDiscard]
public static function attempt(string $value): Attempt
{
$parts = Str::of($value)
Expand All @@ -78,6 +81,7 @@ public static function attempt(string $value): Attempt
)));
}

#[\NoDiscard]
public function toString(): string
{
$command = $this->command->environment()->reduce(
Expand Down
13 changes: 13 additions & 0 deletions src/Job/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function __construct(
*
* @throws \DomainException
*/
#[\NoDiscard]
public static function of(string $value): self
{
return self::maybe($value)->match(
Expand All @@ -60,6 +61,7 @@ public static function of(string $value): self
*
* @return Maybe<self>
*/
#[\NoDiscard]
public static function maybe(string $value): Maybe
{
$parts = Str::of($value)->split(' ');
Expand Down Expand Up @@ -104,6 +106,7 @@ public static function maybe(string $value): Maybe
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function everyMinute(): self
{
return new self(
Expand All @@ -120,6 +123,7 @@ public static function everyMinute(): self
*
* @param int<0, 59> $minute
*/
#[\NoDiscard]
public static function everyHourAt(int $minute): self
{
return new self(
Expand All @@ -137,6 +141,7 @@ public static function everyHourAt(int $minute): self
* @param int<0, 23> $hour
* @param int<0, 59> $minute
*/
#[\NoDiscard]
public static function everyDayAt(int $hour, int $minute): self
{
return new self(
Expand All @@ -154,6 +159,7 @@ public static function everyDayAt(int $hour, int $minute): self
* @param int<0, 23> $hour
* @param int<0, 59> $minute
*/
#[\NoDiscard]
public static function everyMondayAt(int $hour, int $minute): self
{
return new self(
Expand All @@ -171,6 +177,7 @@ public static function everyMondayAt(int $hour, int $minute): self
* @param int<0, 23> $hour
* @param int<0, 59> $minute
*/
#[\NoDiscard]
public static function everyTuesdayAt(int $hour, int $minute): self
{
return new self(
Expand All @@ -188,6 +195,7 @@ public static function everyTuesdayAt(int $hour, int $minute): self
* @param int<0, 23> $hour
* @param int<0, 59> $minute
*/
#[\NoDiscard]
public static function everyWednesdayAt(int $hour, int $minute): self
{
return new self(
Expand All @@ -205,6 +213,7 @@ public static function everyWednesdayAt(int $hour, int $minute): self
* @param int<0, 23> $hour
* @param int<0, 59> $minute
*/
#[\NoDiscard]
public static function everyThursdayAt(int $hour, int $minute): self
{
return new self(
Expand All @@ -222,6 +231,7 @@ public static function everyThursdayAt(int $hour, int $minute): self
* @param int<0, 23> $hour
* @param int<0, 59> $minute
*/
#[\NoDiscard]
public static function everyFridayAt(int $hour, int $minute): self
{
return new self(
Expand All @@ -239,6 +249,7 @@ public static function everyFridayAt(int $hour, int $minute): self
* @param int<0, 23> $hour
* @param int<0, 59> $minute
*/
#[\NoDiscard]
public static function everySaturdayAt(int $hour, int $minute): self
{
return new self(
Expand All @@ -256,6 +267,7 @@ public static function everySaturdayAt(int $hour, int $minute): self
* @param int<0, 23> $hour
* @param int<0, 59> $minute
*/
#[\NoDiscard]
public static function everySundayAt(int $hour, int $minute): self
{
return new self(
Expand All @@ -267,6 +279,7 @@ public static function everySundayAt(int $hour, int $minute): self
);
}

#[\NoDiscard]
public function toString(): string
{
return \sprintf(
Expand Down
5 changes: 5 additions & 0 deletions src/Job/Schedule/DaysOfMonth.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ private function __construct(string $value)
*
* @throws \DomainException
*/
#[\NoDiscard]
public static function of(string $value): self
{
return self::maybe($value)->match(
Expand All @@ -37,6 +38,7 @@ public static function of(string $value): self
*
* @return Maybe<self>
*/
#[\NoDiscard]
public static function maybe(string $value): Maybe
{
return Maybe::just($value)
Expand All @@ -47,6 +49,7 @@ public static function maybe(string $value): Maybe
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function each(): self
{
return new self('*');
Expand All @@ -57,11 +60,13 @@ public static function each(): self
*
* @param int<1, 31> $day
*/
#[\NoDiscard]
public static function at(int $day): self
{
return new self((string) $day);
}

#[\NoDiscard]
public function toString(): string
{
return $this->value;
Expand Down
5 changes: 5 additions & 0 deletions src/Job/Schedule/DaysOfWeek.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ private function __construct(string $value)
*
* @throws \DomainException
*/
#[\NoDiscard]
public static function of(string $value): self
{
return self::maybe($value)->match(
Expand All @@ -37,6 +38,7 @@ public static function of(string $value): self
*
* @return Maybe<self>
*/
#[\NoDiscard]
public static function maybe(string $value): Maybe
{
return Maybe::just($value)
Expand All @@ -47,6 +49,7 @@ public static function maybe(string $value): Maybe
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function each(): self
{
return new self('*');
Expand All @@ -57,11 +60,13 @@ public static function each(): self
*
* @param int<0, 6> $day
*/
#[\NoDiscard]
public static function at(int $day): self
{
return new self((string) $day);
}

#[\NoDiscard]
public function toString(): string
{
return $this->value;
Expand Down
5 changes: 5 additions & 0 deletions src/Job/Schedule/Hours.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ private function __construct(string $value)
*
* @throws \DomainException
*/
#[\NoDiscard]
public static function of(string $value): self
{
return self::maybe($value)->match(
Expand All @@ -37,6 +38,7 @@ public static function of(string $value): self
*
* @return Maybe<self>
*/
#[\NoDiscard]
public static function maybe(string $value): Maybe
{
return Maybe::just($value)
Expand All @@ -47,6 +49,7 @@ public static function maybe(string $value): Maybe
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function each(): self
{
return new self('*');
Expand All @@ -57,11 +60,13 @@ public static function each(): self
*
* @param int<0, 23> $hour
*/
#[\NoDiscard]
public static function at(int $hour): self
{
return new self((string) $hour);
}

#[\NoDiscard]
public function toString(): string
{
return $this->value;
Expand Down
5 changes: 5 additions & 0 deletions src/Job/Schedule/Minutes.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ private function __construct(string $value)
*
* @throws \DomainException
*/
#[\NoDiscard]
public static function of(string $value): self
{
return self::maybe($value)->match(
Expand All @@ -37,6 +38,7 @@ public static function of(string $value): self
*
* @return Maybe<self>
*/
#[\NoDiscard]
public static function maybe(string $value): Maybe
{
return Maybe::just($value)
Expand All @@ -47,6 +49,7 @@ public static function maybe(string $value): Maybe
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function each(): self
{
return new self('*');
Expand All @@ -57,11 +60,13 @@ public static function each(): self
*
* @param int<0, 59> $minute
*/
#[\NoDiscard]
public static function at(int $minute): self
{
return new self((string) $minute);
}

#[\NoDiscard]
public function toString(): string
{
return $this->value;
Expand Down
5 changes: 5 additions & 0 deletions src/Job/Schedule/Months.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ private function __construct(string $value)
*
* @throws \DomainException
*/
#[\NoDiscard]
public static function of(string $value): self
{
return self::maybe($value)->match(
Expand All @@ -37,6 +38,7 @@ public static function of(string $value): self
*
* @return Maybe<self>
*/
#[\NoDiscard]
public static function maybe(string $value): Maybe
{
return Maybe::just($value)
Expand All @@ -47,6 +49,7 @@ public static function maybe(string $value): Maybe
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function each(): self
{
return new self('*');
Expand All @@ -57,11 +60,13 @@ public static function each(): self
*
* @param int<1, 12> $month
*/
#[\NoDiscard]
public static function at(int $month): self
{
return new self((string) $month);
}

#[\NoDiscard]
public function toString(): string
{
return $this->value;
Expand Down
1 change: 1 addition & 0 deletions src/Job/Schedule/Range.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public function __construct(string $pattern)
$this->pattern = $pattern;
}

#[\NoDiscard]
public function __invoke(string $value): bool
{
if ($value === '*') {
Expand Down
3 changes: 3 additions & 0 deletions src/Read.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ private function __construct(Command $command)
/**
* @return Attempt<Sequence<Job>>
*/
#[\NoDiscard]
public function __invoke(Server $server): Attempt
{
return $server
Expand Down Expand Up @@ -59,6 +60,7 @@ public function __invoke(Server $server): Attempt
);
}

#[\NoDiscard]
public static function forConnectedUser(): self
{
return new self(
Expand All @@ -70,6 +72,7 @@ public static function forConnectedUser(): self
/**
* @param non-empty-string $user
*/
#[\NoDiscard]
public static function forUser(string $user): self
{
return new self(
Expand Down