• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fnagel / t3extblog / 23823603081

31 Mar 2026 11:05PM UTC coverage: 37.437% (-12.6%) from 50.045%
23823603081

push

github

fnagel
[FEATURE] Add YAML lint to composer scripts and CI

Using the new TYPO3 14.2 built in YAML linter.

https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/13.3/Feature-104973-ActivateLintYamlExecutableForTYPO3.html

1256 of 3355 relevant lines covered (37.44%)

3.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.35
/Classes/Domain/Model/AbstractSubscriber.php
1
<?php
2

3
namespace FelixNagel\T3extblog\Domain\Model;
4

5
/**
6
 * This file is part of the "t3extblog" Extension for TYPO3 CMS.
7
 *
8
 * For the full copyright and license information, please read the
9
 * LICENSE.txt file that was distributed with this source code.
10
 */
11

12
use TYPO3\CMS\Core\Crypto\HashService;
13
use FelixNagel\T3extblog\Validation\Validator\PrivacyPolicyValidator;
14
use TYPO3\CMS\Core\Utility\GeneralUtility;
15
use TYPO3\CMS\Extbase\Annotation as Extbase;
16

17
/**
18
 * AbstractSubscriber.
19
 */
20
abstract class AbstractSubscriber extends AbstractEntity
21
{
22
    protected bool $hidden = true;
23

24
    #[Extbase\Validate(['validator' => 'NotEmpty'])]
25
    #[Extbase\Validate(['validator' => 'EmailAddress'])]
26
    protected ?string $email = null;
27

28
    protected ?\DateTime $lastSent = null;
29

30
    protected ?string $code = null;
31

32
    #[Extbase\Validate(['validator' => PrivacyPolicyValidator::class, 'options' => ['key' => 'blog']])]
33
    protected bool $privacyPolicyAccepted = false;
34

35
    /**
36
     * If the subscriber is valid for opt-in email.
37
     */
38
    public function isValidForOptin(): bool
4✔
39
    {
40
        return $this->isHidden() && !$this->isDeleted() && $this->getLastSent() === null;
4✔
41
    }
42

43
    public function getEmail(): string
3✔
44
    {
45
        return $this->email;
3✔
46
    }
47

48
    public function setEmail(string $email): void
14✔
49
    {
50
        $this->email = $email;
14✔
51
    }
52

53
    public function getLastSent(): ?\DateTime
8✔
54
    {
55
        return $this->lastSent;
8✔
56
    }
57

58
    public function setLastSent(\DateTime $lastSent): void
10✔
59
    {
60
        $this->lastSent = $lastSent;
10✔
61
    }
62

63
    public function getCode(): string
2✔
64
    {
65
        return $this->code;
2✔
66
    }
67

68
    public function setCode(string $code): void
×
69
    {
70
        $this->code = $code;
×
71
    }
72

73
    protected function createCode(): void
4✔
74
    {
75
        $now = new \DateTime();
4✔
76
        /** @noinspection NonSecureUniqidUsageInspection */
77
        $input = $this->email.$now->getTimestamp().uniqid();
4✔
78

79
        $this->code = substr(GeneralUtility::makeInstance(HashService::class)->hmac($input, $now->getTimestamp()), 0, 32);
4✔
80
    }
81

82
    public function hasPrivacyPolicyAccepted(): bool
×
83
    {
84
        return $this->privacyPolicyAccepted;
×
85
    }
86

87
    public function setPrivacyPolicyAccepted(bool $privacyPolicyAccepted): void
×
88
    {
89
        $this->privacyPolicyAccepted = $privacyPolicyAccepted;
×
90
    }
91

92
    /**
93
     * Update subscriber.
94
     */
95
    public function updateAuth(): void
4✔
96
    {
97
        $this->setLastSent(new \DateTime());
4✔
98
        $this->createCode();
4✔
99
    }
100

101
    /**
102
     * Returns prepared mailto array.
103
     */
104
    public function getMailTo(): array
2✔
105
    {
106
        $mail = [$this->getEmail() => ''];
2✔
107

108
        if (method_exists($this, 'getName')) {
2✔
109
            $mail = [$this->getEmail() => $this->getName()];
1✔
110
        }
111

112
        return $mail;
2✔
113
    }
114

115
    /**
116
     * Checks if the authCode is still valid.
117
     */
118
    public function isAuthCodeExpired(string $expireDate): bool
4✔
119
    {
120
        $now = new \DateTime();
4✔
121
        $expire = clone $this->getLastSent();
4✔
122

123
        return $now > $expire->modify($expireDate);
4✔
124
    }
125
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc