Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
freescout-help-desk authored and StyleCIBot committed Aug 4, 2018
1 parent ea7e6be commit e4a19b2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
23 changes: 13 additions & 10 deletions app/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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++) {
Expand All @@ -98,6 +100,7 @@ public static function getPath($id)
if ($first == -1) {
$first = 0;
}

return $first.DIRECTORY_SEPARATOR.$second.DIRECTORY_SEPARATOR;
}

Expand All @@ -115,7 +118,7 @@ public static function typeNameToInt($type_name)

/**
* Get attachment public URL.
*
*
* @return string
*/
public function getUrl()
Expand All @@ -125,7 +128,7 @@ public function getUrl()

/**
* Convert size into human readable format.
*
*
* @return string
*/
public function getSizeName()
Expand All @@ -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;
}
Expand Down
10 changes: 6 additions & 4 deletions app/Console/Commands/FetchEmails.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FetchEmails extends Command

/**
* Current mailbox.
*
*
* @var Mailbox
*/
public $mailbox;
Expand Down Expand Up @@ -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)
Expand All @@ -292,6 +293,7 @@ public function saveAttachments($email_attachments, $thread_id)
$has_attachments = true;
}
}

return $has_attachments;
}

Expand Down
6 changes: 3 additions & 3 deletions app/Conversation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAttachmentsTable extends Migration
{
Expand Down

0 comments on commit e4a19b2

Please sign in to comment.