Code Duplication    Length = 17-17 lines in 3 locations

src/Charcoal/Object/ObjectRevision.php 1 location

@@ 185-201 (lines=17) @@
182
     * @throws InvalidArgumentException If the timestamp is invalid.
183
     * @return ObjectRevision Chainable
184
     */
185
    public function setRevTs($revTs)
186
    {
187
        if ($revTs === null) {
188
            $this->revTs = null;
189
            return $this;
190
        }
191
        if (is_string($revTs)) {
192
            $revTs = new DateTime($revTs);
193
        }
194
        if (!($revTs instanceof DateTimeInterface)) {
195
            throw new InvalidArgumentException(
196
                'Invalid "Revision Date" value. Must be a date/time string or a DateTimeInterface object.'
197
            );
198
        }
199
        $this->revTs = $revTs;
200
        return $this;
201
    }
202
203
    /**
204
     * @return DateTimeInterface|null

src/Charcoal/Object/TimestampableTrait.php 2 locations

@@ 32-48 (lines=17) @@
29
     * @throws InvalidArgumentException If the provided date/time is invalid.
30
     * @return self
31
     */
32
    public function setCreated($created)
33
    {
34
        if ($created === null) {
35
            $this->created = null;
36
            return $this;
37
        }
38
        if (is_string($created)) {
39
            $created = new DateTime($created);
40
        }
41
        if (!($created instanceof DateTimeInterface)) {
42
            throw new InvalidArgumentException(
43
                'Invalid "Created" value. Must be a date/time string or a DateTime object.'
44
            );
45
        }
46
        $this->created = $created;
47
        return $this;
48
    }
49
50
    /**
51
     * @return DateTimeInterface|null
@@ 63-79 (lines=17) @@
60
     * @throws InvalidArgumentException If the provided date/time is invalid.
61
     * @return self
62
     */
63
    public function setLastModified($lastModified)
64
    {
65
        if ($lastModified === null) {
66
            $this->lastModified = null;
67
            return $this;
68
        }
69
        if (is_string($lastModified)) {
70
            $lastModified = new DateTime($lastModified);
71
        }
72
        if (!($lastModified instanceof DateTimeInterface)) {
73
            throw new InvalidArgumentException(
74
                'Invalid "Last Modified" value. Must be a date/time string or a DateTime object.'
75
            );
76
        }
77
        $this->lastModified = $lastModified;
78
        return $this;
79
    }
80
81
    /**
82
     * @return DateTimeInterface|null