Skip to content

Commit

Permalink
added content type constants and translation
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnickell committed Aug 19, 2017
1 parent d90ca01 commit e166aae
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Application/Mail/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ class Message
*/
public const DEFAULT_CHARSET = 'utf-8';

/**
* HTML content type
*
* @var string
*/
public const CONTENT_TYPE_HTML = 'text/html';

/**
* Plain content type
*
* @var string
*/
public const CONTENT_TYPE_PLAIN = 'text/plain';

/**
* Subject
*
Expand Down
16 changes: 16 additions & 0 deletions src/Application/Translation/Exception/TranslationException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php declare(strict_types=1);

namespace Novuso\Common\Application\Translation\Exception;

use Novuso\System\Exception\SystemException;

/**
* TranslationException is thrown for translation errors
*
* @copyright Copyright (c) 2017, Novuso. <http://novuso.com>
* @license http://opensource.org/licenses/MIT The MIT License
* @author John Nickell <email@johnnickell.com>
*/
class TranslationException extends SystemException
{
}
56 changes: 56 additions & 0 deletions src/Application/Translation/TranslatorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php declare(strict_types=1);

namespace Novuso\Common\Application\Translation;

use Novuso\Common\Application\Translation\Exception\TranslationException;

/**
* TranslatorInterface is the interface for a translator
*
* @copyright Copyright (c) 2017, Novuso. <http://novuso.com>
* @license http://opensource.org/licenses/MIT The MIT License
* @author John Nickell <email@johnnickell.com>
*/
interface TranslatorInterface
{
/**
* Translates the message for the given key
*
* @param string $key The message key
* @param array $parameters The message parameters
* @param string|null $domain The message domain or null for default
* @param string|null $locale The locale or null for default
*
* @return string
*
* @throws TranslationException When an error occurs
*/
public function translate(
string $key,
array $parameters = [],
?string $domain = null,
?string $locale = null
): string;

/**
* Translates the message choice for the given key and index
*
* This method is generally implemented for pluralization or instances when
* the translation may depend on some dynamic variable.
*
* @param string $key The message key
* @param int $index The message index
* @param array $parameters The message parameters
* @param null|string $domain The message domain or null for default
* @param null|string $locale The locale or null for default
*
* @return string
*/
public function choice(
string $key,
int $index,
array $parameters = [],
?string $domain = null,
?string $locale = null
): string;
}

0 comments on commit e166aae

Please sign in to comment.