Adds a ViewpointDecorationEventData class for hooks that want to provide a specific hook for scene manipulation.

This commit is contained in:
Vassyli
2017-12-25 14:46:39 +01:00
parent 56c80e3f8d
commit af6a6cbff0
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace LotGD\Core\Events;
use LotGD\Core\Exceptions\ArgumentException;
use LotGD\Core\Models\Viewpoint;
class ViewpointDecorationEventData extends EventContextData
{
/**
* ViewpointDecorationEventData constructor.
* @param array $data Must contain field viewpoint.
* @throws ArgumentException
*/
protected function __construct(array $data)
{
$mustHaveForm = ["viewpoint"];
$doesHaveForm = array_keys($data);
sort($mustHaveForm); sort($doesHaveForm);
if ($doesHaveForm !== $mustHaveForm) {
throw new ArgumentException("A new ViewpointDecoration event must have a viewpoint..");
}
if ($data["viewpoint"] instanceof Viewpoint === false) {
throw new ArgumentException(sprintf(
"data[viewpoint] must be an instance of %s, %s given.",
Viewpoint::class,
get_class($data["viewpoint"])
));
}
parent::__construct($data);
}
}