Mark Scherer 10 years ago
parent
commit
f13cf86949
2 changed files with 35 additions and 19 deletions
  1. 27 14
      src/Mailer/Email.php
  2. 8 5
      src/Utility/Mime.php

+ 27 - 14
src/Mailer/Email.php

@@ -19,6 +19,10 @@ class Email extends CakeEmail {
 
 	protected $_error = null;
 
+	protected $_debug = null;
+
+	protected $_log = [];
+
 	public function __construct($config = null) {
 		if ($config === null) {
 			$config = 'default';
@@ -29,8 +33,8 @@ class Email extends CakeEmail {
 	/**
 	 * Change the layout
 	 *
-	 * @param string $layout Layout to use (or false to use none)
-	 * @return resource EmailLib
+	 * @param string|bool $layout Layout to use (or false to use none)
+	 * @return self
 	 */
 	public function layout($layout = false) {
 		if ($layout !== false) {
@@ -42,8 +46,8 @@ class Email extends CakeEmail {
 	/**
 	 * Set/Get wrapLength
 	 *
-	 * @param int $length Must not be more than CakeEmail::LINE_LENGTH_MUST
-	 * @return int|CakeEmail
+	 * @param int|null $length Must not be more than CakeEmail::LINE_LENGTH_MUST
+	 * @return int|self
 	 */
 	public function wrapLength($length = null) {
 		if ($length === null) {
@@ -57,7 +61,7 @@ class Email extends CakeEmail {
 	 * Set/Get priority
 	 *
 	 * @param int $priority 1 (highest) to 5 (lowest)
-	 * @return int|CakeEmail
+	 * @return int|self
 	 */
 	public function priority($priority = null) {
 		if ($priority === null) {
@@ -71,7 +75,9 @@ class Email extends CakeEmail {
 	 * Fix line length
 	 *
 	 * @overwrite
+	 *
 	 * @param string $message Message to wrap
+	 * @param int $wrapLength
 	 * @return array Wrapped message
 	 */
 	protected function _wrap($message, $wrapLength = CakeEmail::LINE_LENGTH_MUST) {
@@ -99,7 +105,7 @@ class Email extends CakeEmail {
 	 * Ovewrite to allow custom enhancements
 	 *
 	 * @param mixed $config
-	 * @return null|$this
+	 * @return string|null|self
 	 */
 	public function profile($config = null) {
 		if ($config === null) {
@@ -131,7 +137,7 @@ class Email extends CakeEmail {
 	 * Overwrite to allow mimetype detection
 	 *
 	 * @param mixed $attachments
-	 * @return
+	 * @return self
 	 */
 	public function attachments($attachments = null) {
 		if ($attachments === null) {
@@ -174,9 +180,9 @@ class Email extends CakeEmail {
 	 * Add an attachment from file
 	 *
 	 * @param string $file: absolute path
-	 * @param string $filename
+	 * @param string $name
 	 * @param array $fileInfo
-	 * @return resource EmailLib
+	 * @return self
 	 */
 	public function addAttachment($file, $name = null, $fileInfo = []) {
 		$fileInfo['file'] = $file;
@@ -195,7 +201,7 @@ class Email extends CakeEmail {
 	 * @param string $filename to attach it
 	 * @param string $mimeType (leave it empty to get mimetype from $filename)
 	 * @param array $fileInfo
-	 * @return resource EmailLib
+	 * @return self
 	 */
 	public function addBlobAttachment($content, $filename, $mimeType = null, $fileInfo = []) {
 		if ($mimeType === null) {
@@ -216,10 +222,10 @@ class Email extends CakeEmail {
 	 * - contentDisposition
 	 *
 	 * @param string $file: absolute path
-	 * @param string $filename (optional)
+	 * @param string $name (optional)
 	 * @param string $contentId (optional)
 	 * @param array $options Options
-	 * @return mixed resource $EmailLib or string $contentId
+	 * @return string|self $contentId or $this
 	 */
 	public function addEmbeddedAttachment($file, $name = null, $contentId = null, $options = []) {
 		if (empty($name)) {
@@ -253,7 +259,7 @@ class Email extends CakeEmail {
 	 * @param string $mimeType (leave it empty to get mimetype from $filename)
 	 * @param string $contentId (optional)
 	 * @param array $options Options
-	 * @return mixed resource $EmailLib or string $contentId
+	 * @return string|self $contentId or $this
 	 */
 	public function addEmbeddedBlobAttachment($content, $filename, $mimeType = null, $contentId = null, $options = []) {
 		if ($mimeType === null) {
@@ -276,7 +282,9 @@ class Email extends CakeEmail {
 	 * to prevent the same image to overwrite each other and also to only send this image once.
 	 * Allows multiple usage of the same embedded image (using the same cid)
 	 *
-	 * @return string cid of the found file or false if no such attachment can be found
+	 * @param string $file
+	 * @param string $name
+	 * @return bool|string Cid of the found file or false if no such attachment can be found
 	 */
 	protected function _isEmbeddedAttachment($file, $name) {
 		foreach ($this->_attachments as $filename => $fileInfo) {
@@ -290,6 +298,11 @@ class Email extends CakeEmail {
 		return false;
 	}
 
+	/**
+	 * @param $ext
+	 * @param string $default
+	 * @return mixed
+	 */
 	protected function _getMimeByExtension($ext, $default = 'application/octet-stream') {
 		if (!isset($this->_Mime)) {
 			$this->_Mime = new Mime();

+ 8 - 5
src/Utility/Mime.php

@@ -705,6 +705,8 @@ class Mime extends Response {
 
 	/**
 	 * Override constructor
+	 *
+	 * @param array $options
 	 */
 	public function __construct(array $options = []) {
 	}
@@ -712,6 +714,7 @@ class Mime extends Response {
 	/**
 	 * Get all mime types that are supported right now
 	 *
+	 * @param bool $coreHasPrecedence
 	 * @return array
 	 */
 	public function mimeTypes($coreHasPrecedence = false) {
@@ -822,8 +825,8 @@ class Mime extends Response {
 		if ($mimetype) {
 			return $mimetype;
 		}
-		$extension = $this->_getExtension($file);
-		if ($mimeType = $this->getMimeTypeByAlias($extension)) {
+		$extension = static::_getExtension($file);
+		if ($mimeType = static::getMimeTypeByAlias($extension)) {
 			return $mimeType;
 		}
 		return "application/octet-stream";
@@ -834,9 +837,9 @@ class Mime extends Response {
 	 *
 	 * @param string $file
 	 * @param string $default
-	 * @return void
+	 * @return string
 	 */
-	public function getEncoding($file = null, $default = 'utf-8') {
+	public static function getEncoding($file = null, $default = 'utf-8') {
 		if (!function_exists("finfo_open")) {
 			return $default;
 		}
@@ -855,7 +858,7 @@ class Mime extends Response {
 	 * @param String $file The full file name
 	 * @return String ext The file extension
 	 */
-	protected function _getExtension($file) {
+	protected static function _getExtension($file) {
 		$pieces = explode('.', $file);
 		$ext = strtolower(array_pop($pieces));
 		return $ext;