-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mammatus\Cron; | ||
|
||
final readonly class Action | ||
{ | ||
/** @param array<string, mixed> $addOns */ | ||
public function __construct( | ||
public string $type, | ||
public string $name, | ||
public string $schedule, | ||
public string $class, | ||
public array $addOns, | ||
) { | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mammatus\Cron\Composer; | ||
|
||
use Mammatus\Cron\Attributes\Cron; | ||
use Mammatus\Kubernetes\Attributes\SplitOut; | ||
use Roave\BetterReflection\Reflection\ReflectionClass; | ||
use WyriHaximus\Composer\GenerativePluginTooling\Item as ItemContract; | ||
use WyriHaximus\Composer\GenerativePluginTooling\ItemCollector; | ||
|
||
use function array_key_exists; | ||
|
||
final class Collector implements ItemCollector | ||
{ | ||
/** @return iterable<ItemContract> */ | ||
public function collect(ReflectionClass $class): iterable | ||
{ | ||
/** @var array<Cron> $attributes */ | ||
$attributes = []; | ||
foreach ((new \ReflectionClass($class->getName()))->getAttributes() as $attributeReflection) { | ||
$attribute = $attributeReflection->newInstance(); | ||
$attributes[$attribute::class] = $attribute; | ||
} | ||
|
||
if (! array_key_exists(Cron::class, $attributes)) { | ||
return; | ||
} | ||
|
||
yield new Item( | ||
$class->getName(), | ||
$attributes[Cron::class], | ||
Check failure on line 33 in src/Composer/Collector.php GitHub Actions / Continuous Integration / Continuous Integration / Run stan on PHP 8.2 (nts) with highest dependency preference
Check failure on line 33 in src/Composer/Collector.php GitHub Actions / Continuous Integration / Continuous Integration / Run stan on PHP 8.2 (nts) with locked dependency preference
Check failure on line 33 in src/Composer/Collector.php GitHub Actions / Continuous Integration / Continuous Integration / Run stan on PHP 8.2 (nts) with lowest dependency preference
Check failure on line 33 in src/Composer/Collector.php GitHub Actions / Continuous Integration / Continuous Integration / Run stan on PHP 8.2 (zts) with highest dependency preference
Check failure on line 33 in src/Composer/Collector.php GitHub Actions / Continuous Integration / Continuous Integration / Run stan on PHP 8.2 (zts) with locked dependency preference
Check failure on line 33 in src/Composer/Collector.php GitHub Actions / Continuous Integration / Continuous Integration / Run stan on PHP 8.2 (zts) with lowest dependency preference
Check failure on line 33 in src/Composer/Collector.php GitHub Actions / Continuous Integration / Continuous Integration / Run stan on PHP 8.3 (nts) with highest dependency preference
Check failure on line 33 in src/Composer/Collector.php GitHub Actions / Continuous Integration / Continuous Integration / Run stan on PHP 8.3 (nts) with locked dependency preference
Check failure on line 33 in src/Composer/Collector.php GitHub Actions / Continuous Integration / Continuous Integration / Run stan on PHP 8.3 (nts) with lowest dependency preference
Check failure on line 33 in src/Composer/Collector.php GitHub Actions / Continuous Integration / Continuous Integration / Run stan on PHP 8.3 (zts) with highest dependency preference
Check failure on line 33 in src/Composer/Collector.php GitHub Actions / Continuous Integration / Continuous Integration / Run stan on PHP 8.3 (zts) with locked dependency preference
Check failure on line 33 in src/Composer/Collector.php GitHub Actions / Continuous Integration / Continuous Integration / Run stan on PHP 8.3 (zts) with lowest dependency preference
|
||
array_key_exists(SplitOut::class, $attributes), | ||
); | ||
} | ||
} |