summaryrefslogtreecommitdiffstats
path: root/vendor/ipl/scheduler/src/Common/TaskProperties.php
blob: 4ab65e2f022e0cee4448103221bf53970eb329f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php

namespace ipl\Scheduler\Common;

use LogicException;
use Ramsey\Uuid\UuidInterface;

trait TaskProperties
{
    /** @var string */
    protected $description;

    /** @var string Name of this task */
    protected $name;

    /** @var UuidInterface Unique identifier of this task */
    protected $uuid;

    /**
     * Set the description of this task
     *
     * @param ?string $desc
     *
     * @return $this
     */
    public function setDescription(?string $desc): self
    {
        $this->description = $desc;

        return $this;
    }

    public function getDescription(): ?string
    {
        return $this->description;
    }

    public function getName(): string
    {
        if (! $this->name) {
            throw new LogicException('Task name must not be null');
        }

        return $this->name;
    }

    /**
     * Set the name of this Task
     *
     * @param string $name
     *
     * @return $this
     */
    public function setName(string $name): self
    {
        $this->name = $name;

        return $this;
    }

    public function getUuid(): UuidInterface
    {
        if (! $this->uuid) {
            throw new LogicException('Task UUID must not be null');
        }

        return $this->uuid;
    }

    /**
     * Set the UUID of this task
     *
     * @param UuidInterface $uuid
     *
     * @return $this
     */
    public function setUuid(UuidInterface $uuid): self
    {
        $this->uuid = $uuid;

        return $this;
    }
}