Rename Bus Add to Create

This commit is contained in:
James Brooks
2017-03-18 09:30:36 +00:00
parent 7d27c61abe
commit a55575656d
34 changed files with 163 additions and 116 deletions
@@ -11,7 +11,12 @@
namespace CachetHQ\Cachet\Bus\Commands\Component;
final class AddComponentCommand
/**
* This is the create component command class.
*
* @author James Brooks <james@alt-three.com>
*/
final class CreateComponentCommand
{
/**
* The component name.
@@ -12,11 +12,11 @@
namespace CachetHQ\Cachet\Bus\Commands\ComponentGroup;
/**
* This is the add component group command.
* This is the create component group command.
*
* @author James Brooks <james@alt-three.com>
*/
final class AddComponentGroupCommand
final class CreateComponentGroupCommand
{
/**
* The component group name.
@@ -11,7 +11,13 @@
namespace CachetHQ\Cachet\Bus\Commands\Metric;
final class AddMetricCommand
/**
* This is the create metric command class.
*
* @author Joseph Cohen <joe@alt-three.com>
* @author James Brooks <james@alt-three.com>
*/
final class CreateMetricCommand
{
/**
* The metric name.
@@ -13,7 +13,13 @@ namespace CachetHQ\Cachet\Bus\Commands\Metric;
use CachetHQ\Cachet\Models\Metric;
final class AddMetricPointCommand
/**
* This is the create metric point command class.
*
* @author Joseph Cohen <joe@alt-three.com>
* @author James Brooks <james@alt-three.com>
*/
final class CreateMetricPointCommand
{
/**
* The metric to add.
@@ -12,11 +12,11 @@
namespace CachetHQ\Cachet\Bus\Commands\User;
/**
* This is the add user command.
* This is the create user command.
*
* @author James Brooks <james@alt-three.com>
*/
final class AddUserCommand
final class CreateUserCommand
{
/**
* The user username.
@@ -15,7 +15,12 @@ use CachetHQ\Cachet\Bus\Events\ActionInterface;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\User;
final class ComponentWasAddedEvent implements ActionInterface, ComponentEventInterface
/**
* This is the component was created event class.
*
* @author James Brooks <james@alt-three.com>
*/
final class ComponentWasCreatedEvent implements ActionInterface, ComponentEventInterface
{
/**
* The user who added the component.
@@ -15,7 +15,12 @@ use CachetHQ\Cachet\Bus\Events\ActionInterface;
use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Cachet\Models\User;
final class ComponentGroupWasAddedEvent implements ActionInterface, ComponentGroupEventInterface
/**
* This is the component group was created event class.
*
* @author James Brooks <james@alt-three.com>
*/
final class ComponentGroupWasCreatedEvent implements ActionInterface, ComponentGroupEventInterface
{
/**
* The user who added the component group.
@@ -15,7 +15,12 @@ use CachetHQ\Cachet\Bus\Events\ActionInterface;
use CachetHQ\Cachet\Models\MetricPoint;
use CachetHQ\Cachet\Models\User;
final class MetricPointWasAddedEvent implements ActionInterface, MetricEventInterface
/**
* This is the metric point was created event class.
*
* @author James Brooks <james@alt-three.com>
*/
final class MetricPointWasCreatedEvent implements ActionInterface, MetricEventInterface
{
/**
* The user who added the metric point.
@@ -15,7 +15,12 @@ use CachetHQ\Cachet\Bus\Events\ActionInterface;
use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Cachet\Models\User;
final class MetricWasAddedEvent implements ActionInterface, MetricEventInterface
/**
* This is the metric was created event class.
*
* @author James Brooks <james@alt-three.com>
*/
final class MetricWasCreatedEvent implements ActionInterface, MetricEventInterface
{
/**
* The user who added the metric.
@@ -14,7 +14,12 @@ namespace CachetHQ\Cachet\Bus\Events\User;
use CachetHQ\Cachet\Bus\Events\ActionInterface;
use CachetHQ\Cachet\Models\User;
final class UserWasAddedEvent implements ActionInterface, UserEventInterface
/**
* This is the user was created event class.
*
* @author James Brooks <james@alt-three.com>
*/
final class UserWasCreatedEvent implements ActionInterface, UserEventInterface
{
/**
* The user that has been added.
@@ -11,12 +11,17 @@
namespace CachetHQ\Cachet\Bus\Handlers\Commands\Component;
use CachetHQ\Cachet\Bus\Commands\Component\AddComponentCommand;
use CachetHQ\Cachet\Bus\Events\Component\ComponentWasAddedEvent;
use CachetHQ\Cachet\Bus\Commands\Component\CreateComponentCommand;
use CachetHQ\Cachet\Bus\Events\Component\ComponentWasCreatedEvent;
use CachetHQ\Cachet\Models\Component;
use Illuminate\Contracts\Auth\Guard;
class AddComponentCommandHandler
/**
* This is the add component command handler class.
*
* @author James Brooks <james@alt-three.com>
*/
class CreateComponentCommandHandler
{
/**
* The authentication guard instance.
@@ -40,15 +45,15 @@ class AddComponentCommandHandler
/**
* Handle the add component command.
*
* @param \CachetHQ\Cachet\Bus\Commands\Component\AddComponentCommand $command
* @param \CachetHQ\Cachet\Bus\Commands\Component\CreateComponentCommand $command
*
* @return \CachetHQ\Cachet\Models\Component
*/
public function handle(AddComponentCommand $command)
public function handle(CreateComponentCommand $command)
{
$component = Component::create($this->filter($command));
event(new ComponentWasAddedEvent($this->auth->user(), $component));
event(new ComponentWasCreatedEvent($this->auth->user(), $component));
return $component;
}
@@ -56,11 +61,11 @@ class AddComponentCommandHandler
/**
* Filter the command data.
*
* @param \CachetHQ\Cachet\Bus\Commands\Incident\AddComponentCommand $command
* @param \CachetHQ\Cachet\Bus\Commands\Incident\CreateComponentCommand $command
*
* @return array
*/
protected function filter(AddComponentCommand $command)
protected function filter(CreateComponentCommand $command)
{
$params = [
'name' => $command->name,
@@ -11,12 +11,12 @@
namespace CachetHQ\Cachet\Bus\Handlers\Commands\ComponentGroup;
use CachetHQ\Cachet\Bus\Commands\ComponentGroup\AddComponentGroupCommand;
use CachetHQ\Cachet\Bus\Events\ComponentGroup\ComponentGroupWasAddedEvent;
use CachetHQ\Cachet\Bus\Commands\ComponentGroup\CreateComponentGroupCommand;
use CachetHQ\Cachet\Bus\Events\ComponentGroup\ComponentGroupWasCreatedEvent;
use CachetHQ\Cachet\Models\ComponentGroup;
use Illuminate\Contracts\Auth\Guard;
class AddComponentGroupCommandHandler
class CreateComponentGroupCommandHandler
{
/**
* The authentication guard instance.
@@ -26,7 +26,7 @@ class AddComponentGroupCommandHandler
protected $auth;
/**
* Create a new add component group command handler instance.
* Create a new create component group command handler instance.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
*
@@ -38,13 +38,13 @@ class AddComponentGroupCommandHandler
}
/**
* Handle the add component group command.
* Handle the create component group command.
*
* @param \CachetHQ\Cachet\Bus\Commands\ComponentGroup\AddComponentGroupCommand $command
* @param \CachetHQ\Cachet\Bus\Commands\ComponentGroup\CreateComponentGroupCommand $command
*
* @return \CachetHQ\Cachet\Models\ComponentGroup
*/
public function handle(AddComponentGroupCommand $command)
public function handle(CreateComponentGroupCommand $command)
{
$group = ComponentGroup::create([
'name' => $command->name,
@@ -53,7 +53,7 @@ class AddComponentGroupCommandHandler
'visible' => $command->visible,
]);
event(new ComponentGroupWasAddedEvent($this->auth->user(), $group));
event(new ComponentGroupWasCreatedEvent($this->auth->user(), $group));
return $group;
}
@@ -11,12 +11,12 @@
namespace CachetHQ\Cachet\Bus\Handlers\Commands\Metric;
use CachetHQ\Cachet\Bus\Commands\Metric\AddMetricCommand;
use CachetHQ\Cachet\Bus\Events\Metric\MetricWasAddedEvent;
use CachetHQ\Cachet\Bus\Commands\Metric\CreateMetricCommand;
use CachetHQ\Cachet\Bus\Events\Metric\MetricWasCreatedEvent;
use CachetHQ\Cachet\Models\Metric;
use Illuminate\Contracts\Auth\Guard;
class AddMetricCommandHandler
class CreateMetricCommandHandler
{
/**
* The authentication guard instance.
@@ -40,11 +40,11 @@ class AddMetricCommandHandler
/**
* Handle the add metric command.
*
* @param \CachetHQ\Cachet\Bus\Commands\Metric\AddMetricCommand $command
* @param \CachetHQ\Cachet\Bus\Commands\Metric\CreateMetricCommand $command
*
* @return \CachetHQ\Cachet\Models\Metric
*/
public function handle(AddMetricCommand $command)
public function handle(CreateMetricCommand $command)
{
$metric = Metric::create([
'name' => $command->name,
@@ -60,7 +60,7 @@ class AddMetricCommandHandler
'visible' => $command->visible,
]);
event(new MetricWasAddedEvent($this->auth->user(), $metric));
event(new MetricWasCreatedEvent($this->auth->user(), $metric));
return $metric;
}
@@ -11,14 +11,14 @@
namespace CachetHQ\Cachet\Bus\Handlers\Commands\Metric;
use CachetHQ\Cachet\Bus\Commands\Metric\AddMetricPointCommand;
use CachetHQ\Cachet\Bus\Events\Metric\MetricPointWasAddedEvent;
use CachetHQ\Cachet\Bus\Commands\Metric\CreateMetricPointCommand;
use CachetHQ\Cachet\Bus\Events\Metric\MetricPointWasCreatedEvent;
use CachetHQ\Cachet\Models\MetricPoint;
use CachetHQ\Cachet\Services\Dates\DateFactory;
use Carbon\Carbon;
use Illuminate\Contracts\Auth\Guard;
class AddMetricPointCommandHandler
class CreateMetricPointCommandHandler
{
/**
* The authentication guard instance.
@@ -51,11 +51,11 @@ class AddMetricPointCommandHandler
/**
* Handle the add metric point command.
*
* @param \CachetHQ\Cachet\Bus\Commands\Metric\AddMetricPointCommand $command
* @param \CachetHQ\Cachet\Bus\Commands\Metric\CreateMetricPointCommand $command
*
* @return \CachetHQ\Cachet\Models\MetricPoint
*/
public function handle(AddMetricPointCommand $command)
public function handle(CreateMetricPointCommand $command)
{
$metric = $command->metric;
$createdAt = $command->created_at;
@@ -65,7 +65,7 @@ class AddMetricPointCommandHandler
$point->increment('counter', 1);
event(new MetricPointWasAddedEvent($this->auth->user(), $point));
event(new MetricPointWasCreatedEvent($this->auth->user(), $point));
return $point;
}
@@ -73,11 +73,11 @@ class AddMetricPointCommandHandler
/**
* Find or create a metric point.
*
* @param \CachetHQ\Cachet\Bus\Commands\Metric\AddMetricPointCommand $command
* @param \CachetHQ\Cachet\Bus\Commands\Metric\CreateMetricPointCommand $command
*
* @return \CachetHQ\Cachet\Models\MetricPoint
*/
protected function findOrCreatePoint(AddMetricPointCommand $command)
protected function findOrCreatePoint(CreateMetricPointCommand $command)
{
$buffer = Carbon::now()->subMinutes($command->metric->threshold);
@@ -11,25 +11,25 @@
namespace CachetHQ\Cachet\Bus\Handlers\Commands\User;
use CachetHQ\Cachet\Bus\Commands\User\AddUserCommand;
use CachetHQ\Cachet\Bus\Events\User\UserWasAddedEvent;
use CachetHQ\Cachet\Bus\Commands\User\CreateUserCommand;
use CachetHQ\Cachet\Bus\Events\User\UserWasCreatedEvent;
use CachetHQ\Cachet\Models\User;
/**
* This is the add user command handler.
* This is the create user command handler.
*
* @author James Brooks <james@alt-three.com>
*/
class AddUserCommandHandler
class CreateUserCommandHandler
{
/**
* Handle the add user command.
*
* @param \CachetHQ\Cachet\Bus\Commands\User\AddUserCommand $command
* @param \CachetHQ\Cachet\Bus\Commands\User\CreateUserCommand $command
*
* @return \CachetHQ\Cachet\Models\User
*/
public function handle(AddUserCommand $command)
public function handle(CreateUserCommand $command)
{
$user = User::create([
'username' => $command->username,
@@ -38,7 +38,7 @@ class AddUserCommandHandler
'level' => $command->level,
]);
event(new UserWasAddedEvent($user));
event(new UserWasCreatedEvent($user));
return $user;
}
@@ -12,7 +12,7 @@
namespace CachetHQ\Cachet\Bus\Handlers\Commands\User;
use CachetHQ\Cachet\Bus\Commands\User\SignupUserCommand;
use CachetHQ\Cachet\Bus\Events\User\UserWasAddedEvent;
use CachetHQ\Cachet\Bus\Events\User\UserWasCreatedEvent;
use CachetHQ\Cachet\Models\User;
class SignupUserCommandHandler
@@ -33,7 +33,7 @@ class SignupUserCommandHandler
'level' => User::LEVEL_USER,
]);
event(new UserWasAddedEvent($user));
event(new UserWasCreatedEvent($user));
return $user;
}