Skip to content

Commit 65aa73e

Browse files
committed
constants are PascalCase
1 parent e521195 commit 65aa73e

File tree

5 files changed

+29
-20
lines changed

5 files changed

+29
-20
lines changed

.phpstorm.meta.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55
namespace PHPSTORM_META;
66

7-
expectedArguments(\Nette\Mail\Message::setPriority(), 0, \Nette\Mail\Message::HIGH, \Nette\Mail\Message::NORMAL, \Nette\Mail\Message::LOW);
8-
expectedReturnValues(\Nette\Mail\Message::getPriority(), \Nette\Mail\Message::HIGH, \Nette\Mail\Message::NORMAL, \Nette\Mail\Message::LOW);
7+
expectedArguments(\Nette\Mail\Message::setPriority(), 0, \Nette\Mail\Message::High, \Nette\Mail\Message::Normal, \Nette\Mail\Message::Low);
8+
expectedReturnValues(\Nette\Mail\Message::getPriority(), \Nette\Mail\Message::High, \Nette\Mail\Message::Normal, \Nette\Mail\Message::Low);

src/Mail/Message.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,18 @@ class Message extends MimePart
2323
{
2424
/** Priority */
2525
public const
26-
HIGH = 1,
27-
NORMAL = 3,
28-
LOW = 5;
26+
High = 1,
27+
Normal = 3,
28+
Low = 5;
29+
30+
/** @deprecated use Message::High */
31+
public const HIGH = self::High;
32+
33+
/** @deprecated use Message::Normal */
34+
public const NORMAL = self::Normal;
35+
36+
/** @deprecated use Message::Low */
37+
public const LOW = self::Low;
2938

3039
public static array $defaultHeaders = [
3140
'MIME-Version' => '1.0',
@@ -308,7 +317,7 @@ private function createAttachment(
308317

309318
$part->setBody($content);
310319
$part->setContentType($contentType);
311-
$part->setEncoding(preg_match('#(multipart|message)/#A', $contentType) ? self::ENCODING_8BIT : self::ENCODING_BASE64);
320+
$part->setEncoding(preg_match('#(multipart|message)/#A', $contentType) ? self::Encoding8Bit : self::EncodingBase64);
312321
$part->setHeader('Content-Disposition', $disposition . '; filename="' . addcslashes($file, '"\\') . '"');
313322
return $part;
314323
}
@@ -357,17 +366,17 @@ public function build(): static
357366

358367
$alt->setContentType('text/html', 'UTF-8')
359368
->setEncoding(preg_match('#[^\n]{990}#', $mail->htmlBody)
360-
? self::ENCODING_QUOTED_PRINTABLE
361-
: (preg_match('#[\x80-\xFF]#', $mail->htmlBody) ? self::ENCODING_8BIT : self::ENCODING_7BIT))
369+
? self::EncodingQuotedPrintable
370+
: (preg_match('#[\x80-\xFF]#', $mail->htmlBody) ? self::Encoding8Bit : self::Encoding7Bit))
362371
->setBody($mail->htmlBody);
363372
}
364373

365374
$text = $mail->getBody();
366375
$mail->setBody('');
367376
$cursor->setContentType('text/plain', 'UTF-8')
368377
->setEncoding(preg_match('#[^\n]{990}#', $text)
369-
? self::ENCODING_QUOTED_PRINTABLE
370-
: (preg_match('#[\x80-\xFF]#', $text) ? self::ENCODING_8BIT : self::ENCODING_7BIT))
378+
? self::EncodingQuotedPrintable
379+
: (preg_match('#[\x80-\xFF]#', $text) ? self::Encoding8Bit : self::Encoding7Bit))
371380
->setBody($text);
372381

373382
return $mail;

src/Mail/MimePart.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ class MimePart
2424

2525
/** encoding */
2626
public const
27-
ENCODING_BASE64 = 'base64',
28-
ENCODING_7BIT = '7bit',
29-
ENCODING_8BIT = '8bit',
30-
ENCODING_QUOTED_PRINTABLE = 'quoted-printable';
27+
EncodingBase64 = 'base64',
28+
Encoding7Bit = '7bit',
29+
Encoding8Bit = '8bit',
30+
EncodingQuotedPrintable = 'quoted-printable';
3131

3232
/** @internal */
3333
public const EOL = "\r\n";
@@ -232,19 +232,19 @@ public function getEncodedMessage(): string
232232
$body = $this->body;
233233
if ($body !== '') {
234234
switch ($this->getEncoding()) {
235-
case self::ENCODING_QUOTED_PRINTABLE:
235+
case self::EncodingQuotedPrintable:
236236
$output .= quoted_printable_encode($body);
237237
break;
238238

239-
case self::ENCODING_BASE64:
239+
case self::EncodingBase64:
240240
$output .= rtrim(chunk_split(base64_encode($body), self::LineLength, self::EOL));
241241
break;
242242

243-
case self::ENCODING_7BIT:
243+
case self::Encoding7Bit:
244244
$body = preg_replace('#[\x80-\xFF]+#', '', $body);
245245
// break omitted
246246

247-
case self::ENCODING_8BIT:
247+
case self::Encoding8Bit:
248248
$body = str_replace(["\x00", "\r"], '', $body);
249249
$body = str_replace("\n", self::EOL, $body);
250250
$output .= $body;

tests/Mail/Mail.attachment.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Assert::match(<<<'EOD'
4949

5050
$mail = new Message;
5151
$mail->addAttachment(__DIR__ . '/fixtures/example.zip', null, 'application/zip')
52-
->setEncoding(Message::ENCODING_QUOTED_PRINTABLE);
52+
->setEncoding(Message::EncodingQuotedPrintable);
5353
$mailer->send($mail);
5454

5555
Assert::match(<<<'EOD'

tests/Mail/Mail.headers.002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ $mail->addReplyTo('[email protected]');
2626
$mail->setReturnPath('[email protected]');
2727

2828
$mail->setSubject('Hello Jane!');
29-
$mail->setPriority(Message::HIGH);
29+
$mail->setPriority(Message::High);
3030

3131
$mail->setHeader('X-Gmail-Label', 'love');
3232

0 commit comments

Comments
 (0)