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

(Refactor) Simplify Useless Variables #1134

Merged
merged 2 commits into from
Feb 13, 2020
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
4 changes: 1 addition & 3 deletions app/Console/Commands/DemoSeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ private function search($id)

$client = new \App\Services\MovieScrapper(config('api-keys.tmdb'), config('api-keys.tvdb'), config('api-keys.omdb'));

$meta = $client->scrape('movie', null, $id);

return $meta;
return $client->scrape('movie', null, $id);
}

private function ids()
Expand Down
48 changes: 12 additions & 36 deletions app/Helpers/Markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,9 @@ protected function lines(array $lines)
$markup .= isset($Block['markup']) ? $Block['markup'] : $this->element($Block['element']);
}

$markup .= "\n";

// ~

return $markup;
return $markup."\n";
}

protected function isBlockContinuable($Type)
Expand All @@ -296,7 +294,7 @@ protected function blockCode($Line, $Block = null)
if ($Line['indent'] >= 4) {
$text = substr($Line['body'], 4);

$Block = [
return [
'element' => [
'name' => 'pre',
'handler' => 'element',
Expand All @@ -306,8 +304,6 @@ protected function blockCode($Line, $Block = null)
],
],
];

return $Block;
}
}

Expand Down Expand Up @@ -395,16 +391,14 @@ protected function blockFencedCode($Line)
];
}

$Block = [
return [
'char' => $Line['text'][0],
'element' => [
'name' => 'pre',
'handler' => 'element',
'text' => $Element,
],
];

return $Block;
}
}

Expand Down Expand Up @@ -460,15 +454,13 @@ protected function blockHeader($Line)

$text = trim($Line['text'], '# ');

$Block = [
return [
'element' => [
'name' => 'h'.min(6, $level),
'text' => $text,
'handler' => 'line',
],
];

return $Block;
}
}

Expand Down Expand Up @@ -583,15 +575,13 @@ protected function blockListComplete(array $Block)
protected function blockQuote($Line)
{
if (preg_match('/^>[ ]?(.*)/', $Line['text'], $matches)) {
$Block = [
return [
'element' => [
'name' => 'blockquote',
'handler' => 'lines',
'text' => (array) $matches[1],
],
];

return $Block;
}
}

Expand Down Expand Up @@ -622,13 +612,11 @@ protected function blockQuoteContinue($Line, array $Block)
protected function blockRule($Line)
{
if (preg_match('/^(['.$Line['text'][0].'])([ ]*\1){2,}[ ]*$/', $Line['text'])) {
$Block = [
return [
'element' => [
'name' => 'hr',
],
];

return $Block;
}
}

Expand Down Expand Up @@ -742,11 +730,9 @@ protected function blockReference($Line)

$this->DefinitionData['Reference'][$id] = $Data;

$Block = [
return [
'hidden' => true,
];

return $Block;
}
}

Expand Down Expand Up @@ -904,15 +890,13 @@ protected function blockTableContinue($Line, array $Block)

protected function paragraph($Line)
{
$Block = [
return [
'element' => [
'name' => 'p',
'text' => $Line['text'],
'handler' => 'line',
],
];

return $Block;
}

//
Expand Down Expand Up @@ -1010,9 +994,7 @@ public function line($text, $nonNestables = [])
$text = substr($text, $markerPosition + 1);
}

$markup .= $this->unmarkedText($text);

return $markup;
return $markup.$this->unmarkedText($text);
}

//
Expand Down Expand Up @@ -1262,7 +1244,7 @@ protected function inlineUrl($Excerpt)
if (preg_match('/\bhttps?:[\/]{2}[^\s<]+\b\/*/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE)) {
$url = $matches[0][0];

$Inline = [
return [
'extent' => strlen($matches[0][0]),
'position' => $matches[0][1],
'element' => [
Expand All @@ -1273,8 +1255,6 @@ protected function inlineUrl($Excerpt)
],
],
];

return $Inline;
}
}

Expand Down Expand Up @@ -1359,9 +1339,7 @@ protected function elements(array $Elements)
$markup .= "\n".$this->element($Element);
}

$markup .= "\n";

return $markup;
return $markup."\n";
}

// ~
Expand Down Expand Up @@ -1390,9 +1368,7 @@ protected function li($lines)

public function parse($text)
{
$markup = $this->text($text);

return $markup;
return $this->text($text);
}

protected function sanitiseElement(array $Element)
Expand Down
3 changes: 1 addition & 2 deletions app/Helpers/MediaInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,8 @@ private function parseFileSize($string)
private function parseBitRate($string)
{
$string = str_replace(' ', '', strtolower($string));
$string = str_replace('kbps', ' kbps', $string);

return $string;
return str_replace('kbps', ' kbps', $string);
}

private function parseWidthHeight($string)
Expand Down
3 changes: 1 addition & 2 deletions app/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ public function getPostNumber()
public function getPageNumber()
{
$result = ($this->getPostNumber() - 1) / 25 + 1;
$result = floor($result);

return $result;
return floor($result);
}
}
3 changes: 1 addition & 2 deletions app/Models/Torrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,8 @@ public function setMediaInfoAttribute($value)
public function getMediaInfo()
{
$parser = new MediaInfo();
$parsed = $parser->parse($this->mediaInfo);

return $parsed;
return $parser->parse($this->mediaInfo);
}

/**
Expand Down
8 changes: 2 additions & 6 deletions app/Models/UserNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ public function user()
*/
public function getExpectedGroupsAttribute()
{
$expected_groups = ['default_groups' => ['1' => 0]];

return $expected_groups;
return ['default_groups' => ['1' => 0]];
}

/**
Expand All @@ -149,9 +147,7 @@ public function getExpectedGroupsAttribute()
*/
public function getExpectedFieldsAttribute()
{
$expected_fields = [];

return $expected_fields;
return [];
}

/**
Expand Down
8 changes: 2 additions & 6 deletions app/Models/UserPrivacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,7 @@ public function user()
*/
public function getExpectedGroupsAttribute()
{
$expected_groups = ['default_groups' => ['1' => 0]];

return $expected_groups;
return ['default_groups' => ['1' => 0]];
}

/**
Expand All @@ -179,9 +177,7 @@ public function getExpectedGroupsAttribute()
*/
public function getExpectedFieldsAttribute()
{
$expected_fields = [];

return $expected_fields;
return [];
}

/**
Expand Down
4 changes: 1 addition & 3 deletions app/Services/Clients/OmdbClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@ public function find($keys, $type = null)

$result = $this->toArray($this->request($url));
if (isset($result['Response']) && $result['Response'] == 'True') {
$result = array_map(function ($value) {
return array_map(function ($value) {
if ($value == 'N/A') {
return;
}

return $value;
}, $result);

return $result;
}
}

Expand Down
4 changes: 1 addition & 3 deletions app/Services/Clients/TmdbClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,13 @@ private function formatImages($images, $path, $image)
return $path.$item['file_path'];
}, $images);

$images = array_filter($images, function ($item) use ($path, $image) {
return array_filter($images, function ($item) use ($path, $image) {
if ($item == $path.$image) {
return false;
}

return true;
});

return $images;
}

private function formatCasts($credits, $role)
Expand Down
4 changes: 1 addition & 3 deletions app/Traits/Encryptable.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ public function getAttribute($key)
$value = parent::getAttribute($key);

if (in_array($key, $this->encryptable)) {
$value = Crypt::decrypt($value);

return $value;
return Crypt::decrypt($value);
}

return $value;
Expand Down
4 changes: 1 addition & 3 deletions app/Traits/TwoStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private function generateCode(int $length = 4, string $prefix = '', string $suff
*/
private function checkTwoStepAuthStatus(int $userId)
{
$twoStepAuth = TwoStepAuth::firstOrCreate(
return TwoStepAuth::firstOrCreate(
[
'userId' => $userId,
],
Expand All @@ -124,8 +124,6 @@ private function checkTwoStepAuthStatus(int $userId)
'authCount' => 0,
]
);

return $twoStepAuth;
}

/**
Expand Down