Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
95.00% covered (success)
95.00%
19 / 20
92.86% covered (success)
92.86%
13 / 14
CRAP
0.00% covered (danger)
0.00%
0 / 1
NotificationSubscription
95.00% covered (success)
95.00%
19 / 20
92.86% covered (success)
92.86%
13 / 14
15
0.00% covered (danger)
0.00%
0 / 1
 __toString
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 setId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getDeliveryType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setDeliveryType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getUser
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setUser
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getNotificationType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setNotificationType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getNotificationTypeArgs
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setNotificationTypeArgs
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCreatedAt
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setCreatedAt
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 testOnlyGetField
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Olz\Entity;
4
5use Doctrine\ORM\Mapping as ORM;
6use Olz\Constants\NotificationDeliveryType;
7use Olz\Constants\NotificationType;
8use Olz\Entity\Common\TestableInterface;
9use Olz\Entity\Users\User;
10use Olz\Repository\NotificationSubscriptionRepository;
11
12#[ORM\Table(name: 'notification_subscriptions')]
13#[ORM\Index(name: 'user_id_index', columns: ['user_id'])]
14#[ORM\Index(name: 'notification_type_index', columns: ['notification_type'])]
15#[ORM\Entity(repositoryClass: NotificationSubscriptionRepository::class)]
16class NotificationSubscription implements TestableInterface {
17    #[ORM\Column(nullable: false)]
18    private NotificationDeliveryType $delivery_type;
19
20    #[ORM\ManyToOne(targetEntity: User::class)]
21    #[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: false)]
22    private User $user;
23
24    #[ORM\Column(nullable: false)]
25    private NotificationType $notification_type;
26
27    #[ORM\Column(type: 'text', nullable: true)]
28    private ?string $notification_type_args;
29
30    #[ORM\Column(type: 'datetime', nullable: false)]
31    private \DateTime $created_at;
32
33    #[ORM\Id]
34    #[ORM\Column(type: 'bigint', nullable: false)]
35    #[ORM\GeneratedValue]
36    private int|string $id;
37
38    public function __toString() {
39        $label = 'NotificationSubscription(';
40        $label .= "delivery_type={$this->getDeliveryType()->value}, ";
41        $label .= "user={$this->getUser()->getId()}, ";
42        $label .= "notification_type={$this->getNotificationType()->value}, ";
43        $label .= "notification_type_args={$this->getNotificationTypeArgs()}, ";
44        $label .= ')';
45        return $label;
46    }
47
48    public function getId(): ?int {
49        return isset($this->id) ? intval($this->id) : null;
50    }
51
52    public function setId(int $new_id): void {
53        $this->id = $new_id;
54    }
55
56    public function getDeliveryType(): NotificationDeliveryType {
57        return $this->delivery_type;
58    }
59
60    public function setDeliveryType(NotificationDeliveryType $new_delivery_type): void {
61        $this->delivery_type = $new_delivery_type;
62    }
63
64    public function getUser(): User {
65        return $this->user;
66    }
67
68    public function setUser(User $new_user): void {
69        $this->user = $new_user;
70    }
71
72    public function getNotificationType(): NotificationType {
73        return $this->notification_type;
74    }
75
76    public function setNotificationType(NotificationType $new_notification_type): void {
77        $this->notification_type = $new_notification_type;
78    }
79
80    public function getNotificationTypeArgs(): ?string {
81        return $this->notification_type_args;
82    }
83
84    public function setNotificationTypeArgs(?string $new_notification_type_args): void {
85        $this->notification_type_args = $new_notification_type_args;
86    }
87
88    public function getCreatedAt(): \DateTime {
89        return $this->created_at;
90    }
91
92    public function setCreatedAt(\DateTime $new_created_at): void {
93        $this->created_at = $new_created_at;
94    }
95
96    // ---
97
98    public function testOnlyGetField(string $field_name): mixed {
99        return $this->{$field_name};
100    }
101}