Adds an AttachmentInterface and adjusted the abstract class Attachment.

This commit is contained in:
Vassyli
2021-01-27 20:05:03 +01:00
committed by Basilius Sauter
parent 2a3a3e7bc2
commit 69434c7bbf
2 changed files with 37 additions and 15 deletions
+9 -15
View File
@@ -3,22 +3,25 @@ declare(strict_types=1);
namespace LotGD\Core;
use Exception;
use LotGD\Core\Models\Scene;
/**
* An attachment to a scene. This is desigend to be subclasses by modules to
* provide functinoality like forms or maybe image attachments to go along with a scene.
*/
abstract class Attachment
abstract class Attachment implements AttachmentInterface
{
protected string $id;
/**
* Construct a new attachment of the given type. Randomly assigns it an ID.
* @param string $type Type of this attachment, in the vendor/module/type format.
* @return Attachment
* @param Game $game
* @param Scene $scene
* @throws Exception
*/
public function __construct(
protected string $type
) {
public function __construct(Game $game, Scene $scene)
{
$this->id = \bin2hex(\random_bytes(8));
}
@@ -31,13 +34,4 @@ abstract class Attachment
{
return $this->id;
}
/**
* Returns the type of this attachment, in vendor/module/type format.
* @return string
*/
public function getType(): string
{
return $this->type;
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace LotGD\Core;
use LotGD\Core\Models\Scene;
interface AttachmentInterface
{
/**
* AttachmentInterface constructor.
* @param Game $g Should not be saved internally.
* @param Scene $scene Should not be saved internally.
*/
public function __construct(Game $g, Scene $scene);
public function getId(): string;
/**
* Returns an array with attachment-specific fields.
* @return array
*/
public function getData(): array;
/**
* @return Action[]
*/
public function getActions(): array;
}