Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
EmailSendResult
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 4
20
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 success
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
 failure
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
 isSuccess
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Services\Communication\DTO;
4
5final class EmailSendResult
6{
7    public function __construct(
8        public readonly bool $success,
9        public readonly ?string $messageId = null,
10        public readonly ?string $to = null,
11        public readonly ?string $providerResponse = null,
12        public readonly ?int $httpStatus = null,
13        public readonly ?string $error = null,
14    ) {}
15
16    public static function success(
17        string $to,
18        ?string $messageId = null,
19        ?string $providerResponse = null,
20        ?int $httpStatus = null
21    ): self {
22        return new self(
23            true,
24            $messageId,
25            $to,
26            $providerResponse,
27            $httpStatus,
28            null
29        );
30    }
31
32    public static function failure(
33        string $to,
34        string $error,
35        ?string $providerResponse = null,
36        ?int $httpStatus = null
37    ): self {
38        return new self(
39            false,
40            null,
41            $to,
42            $providerResponse,
43            $httpStatus,
44            $error
45        );
46    }
47
48    public function isSuccess(): bool
49    {
50        return $this->success;
51    }
52}