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
11 changes: 4 additions & 7 deletions src/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@
*/
final class Job
{
private Schedule $schedule;
private Command $command;

public function __construct(Schedule $schedule, Command $command)
{
$this->schedule = $schedule;
$this->command = $command;
public function __construct(
private Schedule $schedule,
private Command $command,
) {
}

/**
Expand Down
21 changes: 5 additions & 16 deletions src/Job/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,13 @@
*/
final class Schedule
{
private Minutes $minutes;
private Hours $hours;
private DaysOfMonth $daysOfMonth;
private Months $months;
private DaysOfWeek $daysOfWeek;

public function __construct(
Minutes $minutes,
Hours $hours,
DaysOfMonth $daysOfMonth,
Months $months,
DaysOfWeek $daysOfWeek,
private Minutes $minutes,
private Hours $hours,
private DaysOfMonth $daysOfMonth,
private Months $months,
private DaysOfWeek $daysOfWeek,
) {
$this->minutes = $minutes;
$this->hours = $hours;
$this->daysOfMonth = $daysOfMonth;
$this->months = $months;
$this->daysOfWeek = $daysOfWeek;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Job/Schedule/DaysOfMonth.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
*/
final class DaysOfMonth
{
private string $value;

private function __construct(string $value)
private function __construct(private string $value)
{
$this->value = $value;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Job/Schedule/DaysOfWeek.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
*/
final class DaysOfWeek
{
private string $value;

private function __construct(string $value)
private function __construct(private string $value)
{
$this->value = $value;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Job/Schedule/Hours.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
*/
final class Hours
{
private string $value;

private function __construct(string $value)
private function __construct(private string $value)
{
$this->value = $value;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Job/Schedule/Minutes.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
*/
final class Minutes
{
private string $value;

private function __construct(string $value)
private function __construct(private string $value)
{
$this->value = $value;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Job/Schedule/Months.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
*/
final class Months
{
private string $value;

private function __construct(string $value)
private function __construct(private string $value)
{
$this->value = $value;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Job/Schedule/Range.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@
*/
final class Range
{
private string $pattern;

public function __construct(string $pattern)
public function __construct(private string $pattern)
{
$this->pattern = $pattern;
}

#[\NoDiscard]
Expand Down
17 changes: 1 addition & 16 deletions src/Read.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,13 @@
use Innmind\Immutable\{
Sequence,
Attempt,
Maybe,
Monoid\Concat,
};

final class Read
{
private Command $command;

private function __construct(Command $command)
private function __construct(private Command $command)
{
$this->command = $command;
}

/**
Expand All @@ -47,17 +43,6 @@ public function __invoke(Server $server): Attempt
->map(static fn($line) => Job::attempt($line->toString())),
)
->flatMap(self::parse(...));

/**
* @psalm-suppress NamedArgumentNotAllowed
* @var Maybe<Sequence<Job>>
*/
return $jobs->match(
static fn($first, $jobs) => Maybe::all($first, ...$jobs->toList())->map(
static fn(Job ...$jobs) => Sequence::of(...$jobs),
),
static fn() => Maybe::just(Sequence::of()),
);
}

#[\NoDiscard]
Expand Down