Completed
Push — master ( 789244...b6d79a )
by Freek
01:28
created

CouldNotSendCampaign::noListSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Spatie\EmailCampaigns\Exceptions;
4
5
use Exception;
6
use ErrorException;
7
use Illuminate\Mail\Mailable;
8
use Spatie\EmailCampaigns\Mails\CampaignMailable;
9
use Spatie\EmailCampaigns\Mails\UsedInCampaign;
10
use Spatie\EmailCampaigns\Models\Campaign;
11
12
class CouldNotSendCampaign extends Exception
13
{
14
    public static function beingSent(Campaign $campaign): self
15
    {
16
        return new static("The campaign with id `{$campaign->id}` can't be sent, because it is already being sent.");
17
    }
18
19
    public static function invalidMailableClass(Campaign $campaign, string $invalidMailableClass)
20
    {
21
        $shouldExtend = CampaignMailable::class;
22
23
        return new static("The campaign with id `{$campaign->id}` can't be sent, because an invalid mailable class `{$invalidMailableClass}` is set. A valid mailable class must extend `{$shouldExtend}`.");
24
    }
25
26
    public static function alreadySent(Campaign $campaign): self
27
    {
28
        return new static("The campaign with id `{$campaign->id}` can't be sent, because it was already sent.");
29
    }
30
31
    public static function noListSet(Campaign $campaign)
32
    {
33
        return new static("The campaign with id `{$campaign->id}` can't be sent, because there is no list set to send it to.");
34
    }
35
36
    public static function noSubjectSet(Campaign $campaign)
37
    {
38
        return new static("The campaign with id `{$campaign->id}` can't be sent, because no subject has been set.");
39
    }
40
41
    public static function noContent(Campaign $campaign): self
42
    {
43
        return new static("The campaign with id `{$campaign->id}` can't be sent because not content has been set.");
44
    }
45
46
    public static function invalidContent(Campaign $campaign, ErrorException $errorException): self
47
    {
48
        return new static("The campaign with id `{$campaign->id}` can't be sent because the content isn't valid. Please check if the html is valid. DOMDocument reported: `{$errorException->getMessage()}`", 0, $errorException);
49
    }
50
}
51