TimestampableEntity::setCreatedAt()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Tfboe\FmLib\Entity\Helpers;
5
6
use Doctrine\ORM\Mapping as ORM;
7
8
/**
9
 * Trait TimestampableEntity
10
 * @package Tfboe\FmLib\Entity\Helpers
11
 */
12
trait TimestampableEntity
13
{
14
//<editor-fold desc="Fields">
15
  /**
16
   * @var \DateTime
17
   * @\Gedmo\Mapping\Annotation\Timestampable(on="create")
18
   * @ORM\Column(type="datetime")
19
   */
20
  private $createdAt;
21
22
  /**
23
   * @var \DateTime
24
   * @\Gedmo\Mapping\Annotation\Timestampable(on="update")
25
   * @ORM\Column(type="datetime")
26
   */
27
  private $updatedAt;
28
29
//</editor-fold desc="Fields">
30
31
//<editor-fold desc="Public Methods">
32
  /**
33
   * @return \DateTime
34
   */
35
  public function getCreatedAt(): \DateTime
36
  {
37
    return $this->createdAt;
38
  }
39
40
  /**
41
   * @return \DateTime
42
   */
43
  public function getUpdatedAt(): \DateTime
44
  {
45
    return $this->updatedAt;
46
  }
47
48
  /**
49
   * @param \DateTime $createdAt
50
   * @return $this|TimestampableEntity
0 ignored issues
show
Comprehensibility Bug introduced by
The return type TimestampableEntity is a trait, and thus cannot be used for type-hinting in PHP. Maybe consider adding an interface and use that for type-hinting?

In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.

If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.

Loading history...
51
   */
52
  public function setCreatedAt(\DateTime $createdAt)
53
  {
54
    $this->createdAt = $createdAt;
55
    return $this;
56
  }
57
58
  /**
59
   * @param \DateTime $updatedAt
60
   * @return $this|TimestampableEntity
0 ignored issues
show
Comprehensibility Bug introduced by
The return type TimestampableEntity is a trait, and thus cannot be used for type-hinting in PHP. Maybe consider adding an interface and use that for type-hinting?

In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.

If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.

Loading history...
61
   */
62
  public function setUpdatedAt(\DateTime $updatedAt)
63
  {
64
    $this->updatedAt = $updatedAt;
65
    return $this;
66
  }
67
//</editor-fold desc="Public Methods">
68
}
69