From e4a19b27ec9da4b2beb64cf3ca9f10fabf35c7bb Mon Sep 17 00:00:00 2001 From: FreeScout Date: Sat, 4 Aug 2018 11:18:16 +0000 Subject: [PATCH] Apply fixes from StyleCI --- app/Attachment.php | 23 +++++++++++-------- app/Console/Commands/FetchEmails.php | 10 ++++---- app/Conversation.php | 6 ++--- ..._08_04_063414_create_attachments_table.php | 4 ++-- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/app/Attachment.php b/app/Attachment.php index 95fdd8039..32724c103 100644 --- a/app/Attachment.php +++ b/app/Attachment.php @@ -53,12 +53,12 @@ public static function create($name, $mime_type, $type, $content, $thread_id = n $file_name = $name; - $attachment = new Attachment(); + $attachment = new self(); $attachment->thread_id = $thread_id; - $attachment->name = $name; + $attachment->name = $name; $attachment->file_name = $file_name; $attachment->mime_type = $mime_type; - $attachment->type = $type; + $attachment->type = $type; //$attachment->size = Storage::size($file_path); $attachment->save(); @@ -69,20 +69,22 @@ public static function create($name, $mime_type, $type, $content, $thread_id = n if ($attachment->size) { $attachment->save(); } + return true; } /** * Get file path by ID. - * - * @param integer $id + * + * @param int $id + * * @return string */ public static function getPath($id) { $hash = md5($id); - $first = -1; + $first = -1; $second = 0; for ($i = 0; $i < strlen($hash); $i++) { @@ -98,6 +100,7 @@ public static function getPath($id) if ($first == -1) { $first = 0; } + return $first.DIRECTORY_SEPARATOR.$second.DIRECTORY_SEPARATOR; } @@ -115,7 +118,7 @@ public static function typeNameToInt($type_name) /** * Get attachment public URL. - * + * * @return string */ public function getUrl() @@ -125,7 +128,7 @@ public function getUrl() /** * Convert size into human readable format. - * + * * @return string */ public function getSizeName() @@ -138,9 +141,9 @@ public static function formatBytes($size, $precision = 0) $size = (int) $size; if ($size > 0) { $base = log($size) / log(1024); - $suffixes = array(' b', ' KB', ' MB', ' GB', ' TB'); + $suffixes = [' b', ' KB', ' MB', ' GB', ' TB']; - return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)]; + return round(pow(1024, $base - floor($base)), $precision).$suffixes[floor($base)]; } else { return $size; } diff --git a/app/Console/Commands/FetchEmails.php b/app/Console/Commands/FetchEmails.php index 87c481985..b7adf307d 100644 --- a/app/Console/Commands/FetchEmails.php +++ b/app/Console/Commands/FetchEmails.php @@ -31,7 +31,7 @@ class FetchEmails extends Command /** * Current mailbox. - * + * * @var Mailbox */ public $mailbox; @@ -272,9 +272,10 @@ public function saveThread($mailbox_id, $message_id, $in_reply_to, $references, /** * Save attachments from email. - * - * @param array $attachments - * @param integer $thread_id + * + * @param array $attachments + * @param int $thread_id + * * @return bool */ public function saveAttachments($email_attachments, $thread_id) @@ -292,6 +293,7 @@ public function saveAttachments($email_attachments, $thread_id) $has_attachments = true; } } + return $has_attachments; } diff --git a/app/Conversation.php b/app/Conversation.php index 2dde91b1e..be95406e2 100644 --- a/app/Conversation.php +++ b/app/Conversation.php @@ -223,9 +223,9 @@ public function setPreview($text = '') $text = trim(preg_replace('/\s+/', ' ', $text)); // Remove "undetectable" whitespaces - $whitespaces = ["%81", "%7F", "%C5%8D", "%8D", "%8F", "%C2%90", "%C2", "%90", "%9D", "%C2%A0", "%A0", "%C2%AD", "%AD", "%08", "%09", "%0A", "%0D"]; - $text = urlencode($text); - foreach($whitespaces as $char){ + $whitespaces = ['%81', '%7F', '%C5%8D', '%8D', '%8F', '%C2%90', '%C2', '%90', '%9D', '%C2%A0', '%A0', '%C2%AD', '%AD', '%08', '%09', '%0A', '%0D']; + $text = urlencode($text); + foreach ($whitespaces as $char) { $text = str_replace($char, ' ', $text); } $text = urldecode($text); diff --git a/database/migrations/2018_08_04_063414_create_attachments_table.php b/database/migrations/2018_08_04_063414_create_attachments_table.php index 0221569a8..425b0cce4 100644 --- a/database/migrations/2018_08_04_063414_create_attachments_table.php +++ b/database/migrations/2018_08_04_063414_create_attachments_table.php @@ -1,8 +1,8 @@