Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply fixes from StyleCI #24

Merged
merged 1 commit into from
Aug 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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