Skip to content

Upgrades/enums #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 1 addition & 6 deletions src/EnumServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@
namespace LaravelEnso\IO;

use LaravelEnso\Enums\EnumServiceProvider as ServiceProvider;
use LaravelEnso\IO\Enums\IOStatuses;
use LaravelEnso\IO\Enums\IOTypes;

class EnumServiceProvider extends ServiceProvider
{
public $register = [
'ioStatuses' => IOStatuses::class,
'ioTypes' => IOTypes::class,
];
public $register = [];
}
17 changes: 17 additions & 0 deletions src/Enums/IOStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace LaravelEnso\IO\Enums;

use LaravelEnso\Enums\Contracts\Frontend;

enum IOStatus: int implements Frontend
{
case Started = 10;
case Processing = 20;
case Finalized = 30;

public static function registerBy(): string
{
return 'ioStatuses';
}
}
12 changes: 0 additions & 12 deletions src/Enums/IOStatuses.php

This file was deleted.

27 changes: 27 additions & 0 deletions src/Enums/IOType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace LaravelEnso\IO\Enums;

use LaravelEnso\Enums\Contracts\Frontend;
use LaravelEnso\Enums\Contracts\Mappable;

enum IOType: int implements Mappable, Frontend
{
case Import = 1;
case Export = 2;
case Task = 3;

public static function registerBy(): string
{
return 'ioTypes';
}

public function map(): string
{
return match ($this) {
self::Import => 'import',
self::Export => 'export',
self::Task => 'task',
};
}
}
18 changes: 0 additions & 18 deletions src/Enums/IOTypes.php

This file was deleted.

5 changes: 2 additions & 3 deletions src/Events/IOEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\App;
use LaravelEnso\IO\Enums\IOTypes;
use LaravelEnso\IO\Enums\IOType;
use LaravelEnso\IO\Http\Resources\IO;

class IOEvent implements ShouldBroadcast
Expand Down Expand Up @@ -46,7 +45,7 @@ public function broadcastWith()

public function broadcastAs()
{
return App::make(IOTypes::class)::get($this->operation->operationType());
return IOType::from($this->operation->operationType())->map();
}

private function inferiorRole(): bool
Expand Down