1 | <?php |
||
35 | class Mailer extends BaseMailer |
||
36 | { |
||
37 | /** |
||
38 | * @var string |
||
39 | */ |
||
40 | public $apiKey; |
||
41 | |||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | public $apiSecret; |
||
46 | |||
47 | /** |
||
48 | * @var boolean |
||
49 | */ |
||
50 | public $enable = true; |
||
51 | |||
52 | /** |
||
53 | * @var string |
||
54 | */ |
||
55 | public $apiVersion = 'v3.1'; |
||
56 | |||
57 | /** |
||
58 | * @var string |
||
59 | */ |
||
60 | public $apiUrl; |
||
61 | |||
62 | /** |
||
63 | * @var bool |
||
64 | */ |
||
65 | public $secured = true; |
||
66 | |||
67 | /** |
||
68 | * @var \Mailjet\Response |
||
69 | */ |
||
70 | public $apiResponse; |
||
71 | |||
72 | /** |
||
73 | * @inheritdoc |
||
74 | */ |
||
75 | public $messageClass = 'sweelix\mailjet\Message'; |
||
76 | |||
77 | |||
78 | /** |
||
79 | * Sends the specified message. |
||
80 | * @param Message $message |
||
81 | * @since XXX |
||
82 | * @throws InvalidConfigException |
||
83 | */ |
||
84 | public function sendMessage($message) |
||
90 | |||
91 | /** |
||
92 | * Sends multiple messages at once. |
||
93 | * @param Message[] $messages list of email messages, which should be sent. |
||
94 | * @param boolean $returnResponse whether to return the count of successfully sent messages or MailJet's response object |
||
95 | * @return int|\Mailjet\Response number of successfully sent messages, or MailJet's api response if $returnResponse is set to true |
||
96 | * @throws InvalidConfigException |
||
97 | * @todo implement workaround for MailJet's limit of max. 50 recipients (mail addresses?) per API call |
||
98 | */ |
||
99 | public function sendMultiple(array $messages, $returnResponse = false) |
||
159 | } |
||
160 |
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.
Let’s take a look at an example:
Our function
my_function
expects aPost
object, and outputs the author of the post. The base classPost
returns a simple string and outputting a simple string will work just fine. However, the child classBlogPost
which is a sub-type ofPost
instead decided to return anobject
, and is therefore violating the SOLID principles. If aBlogPost
were passed tomy_function
, PHP would not complain, but ultimately fail when executing thestrtoupper
call in its body.