Skip to content
This repository was archived by the owner on Mar 14, 2025. It is now read-only.

Commit 626b249

Browse files
authored
🎨 Code Formatting (#79)
* Codeformatting * Code Formatting * Fix indents * Fix indents * Fix
1 parent c65b28d commit 626b249

File tree

74 files changed

+467
-563
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+467
-563
lines changed

app/Console/Commands/CleanUp.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
use Carbon\Carbon;
88
use Illuminate\Console\Command;
99

10-
class CleanUp extends Command
11-
{
10+
class CleanUp extends Command {
1211

1312
/**
1413
* The name and signature of the console command.
@@ -29,8 +28,7 @@ class CleanUp extends Command
2928
*
3029
* @return void
3130
*/
32-
public function __construct()
33-
{
31+
public function __construct() {
3432
parent::__construct();
3533
}
3634

@@ -39,8 +37,7 @@ public function __construct()
3937
*
4038
* @return mixed
4139
*/
42-
public function handle()
43-
{
40+
public function handle() {
4441
TwitterApiRequest::where('created_at', '<', Carbon::now()->addMinutes(-30))->delete();
4542
SocialLoginProfile::where('spotify_lastRefreshed', '<', Carbon::now()->subHours(6)->toDateTimeString())
4643
->update([

app/Console/Commands/REWE_ParseBon.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
use REWEParser\Parser;
1818
use Spatie\PdfToText\Exceptions\PdfNotFound;
1919

20-
class REWE_ParseBon extends Command
21-
{
20+
class REWE_ParseBon extends Command {
2221

2322
/**
2423
* The name and signature of the console command.
@@ -39,8 +38,7 @@ class REWE_ParseBon extends Command
3938
*
4039
* @return void
4140
*/
42-
public function __construct()
43-
{
41+
public function __construct() {
4442
parent::__construct();
4543
}
4644

@@ -49,19 +47,18 @@ public function __construct()
4947
*
5048
* @return mixed
5149
*/
52-
public function handle()
53-
{
50+
public function handle() {
5451
$files = ReweMailController::fetchMailAttachments($this->argument("days"));
5552

56-
foreach ($files as $bonAttachment) {
53+
foreach($files as $bonAttachment) {
5754
try {
5855
$userEmail = UserEmail::firstOrCreate(["email" => $bonAttachment->getEMail()]);
5956

6057
$filename = $bonAttachment->getFilename();
6158

6259
$receipt = Parser::parseFromPDF($bonAttachment->getFilename(), env('PDFTOTEXT_PATH', '/usr/bin/pdftotext'));
6360

64-
if ($receipt->getBonNr() === null || $receipt->getTimestamp() === null || $receipt->getShopNr() === null) {
61+
if($receipt->getBonNr() === null || $receipt->getTimestamp() === null || $receipt->getShopNr() === null) {
6562
dump("Error while parsing eBon. Some important data can't be retrieved.");
6663
return;
6764
}
@@ -97,7 +94,7 @@ public function handle()
9794

9895
$positions = $receipt->getPositions();
9996

100-
foreach ($positions as $position) {
97+
foreach($positions as $position) {
10198
$product = ReweProduct::firstOrCreate(["name" => $position->getName()]);
10299

103100
ReweBonPosition::updateOrCreate([
@@ -110,28 +107,28 @@ public function handle()
110107
]);
111108
}
112109

113-
if ($bon->wasRecentlyCreated == 1 && $userEmail->verified_user_id != null) {
110+
if($bon->wasRecentlyCreated == 1 && $userEmail->verified_user_id != null) {
114111
try {
115112
$message = "<b>Neuer REWE Einkauf registriert</b>\r\n";
116113
$message .= count($positions) . " Produkte für " . number_format($bon->total, 2, ",", ".") . "\r\n";
117114
$message .= "Erhaltenes Cashback: " . $bon->cashback_rate . "% \r\n";
118115
$message .= "<i>" . $bon->timestamp_bon->format("d.m.Y H:i") . "</i> \r\n";
119116
$message .= "============================ \r\n";
120-
foreach ($positions as $position)
117+
foreach($positions as $position)
121118
$message .= ($position->getWeight() !== null ? $position->getWeight() . "kg" : $position->getAmount() . "x") . " " . $position->getName() . " <i>" . number_format($position->getPriceTotal(), 2, ',', '.') . "€</i> \r\n";
122119
$message .= "============================ \r\n";
123120
$message .= "<a href='https://k118.de/rewe/receipt/" . $bon->id . "'>Bon anzeigen</a>";
124121

125122
TelegramController::sendMessage(User::find($userEmail->verified_user_id), $message);
126-
} catch (TelegramException $e) {
123+
} catch(TelegramException $e) {
127124
report($e);
128125
dump("Error while sending Telegram message");
129126
}
130127
}
131-
} catch (ReceiptParseException $e) {
128+
} catch(ReceiptParseException $e) {
132129
report($e);
133130
dump("Error while parsing eBon. Is the format compatible?");
134-
} catch (PdfNotFound $e) {
131+
} catch(PdfNotFound $e) {
135132
report($e);
136133
}
137134
}

app/Console/Commands/Spotify_CatchNowPlaying.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ public function handle() {
7373
}
7474

7575
$timestamp_start = date('Y-m-d H:i:s', $nowPlaying->timestamp / 1000);
76-
$track_id = $nowPlaying->item->id;
77-
$progress_ms = (int)$nowPlaying->progress_ms;
78-
$context = isset($nowPlaying->context->uri) ? SpotifyContext::firstOrCreate(['uri' => $nowPlaying->context->uri]) : null;
76+
$track_id = $nowPlaying->item->id;
77+
$progress_ms = (int)$nowPlaying->progress_ms;
78+
$context = isset($nowPlaying->context->uri) ? SpotifyContext::firstOrCreate(['uri' => $nowPlaying->context->uri]) : null;
7979

80-
$devices = SpotifyAPIController::getDevices($profile->spotify_accessToken);
80+
$devices = SpotifyAPIController::getDevices($profile->spotify_accessToken);
8181
$activeDevice = null;
8282

8383
foreach($devices->devices as $device) {

app/Console/Commands/Spotify_GetTrackInfo.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
use App\SpotifyTrack;
88
use Carbon\Carbon;
99
use Illuminate\Console\Command;
10+
use Exception;
1011

11-
class Spotify_GetTrackInfo extends Command
12-
{
12+
class Spotify_GetTrackInfo extends Command {
1313
/**
1414
* The name and signature of the console command.
1515
*
@@ -29,8 +29,7 @@ class Spotify_GetTrackInfo extends Command
2929
*
3030
* @return void
3131
*/
32-
public function __construct()
33-
{
32+
public function __construct() {
3433
parent::__construct();
3534
}
3635

@@ -39,8 +38,7 @@ public function __construct()
3938
*
4039
* @return mixed
4140
*/
42-
public function handle()
43-
{
41+
public function handle() {
4442
$tracksWithMissingData = SpotifyTrack::where('bpm', null)
4543
->select('track_id')
4644
->orderBy('updated_at', 'asc')
@@ -60,8 +58,9 @@ public function handle()
6058
try {
6159
$request = SpotifyAPIController::getAudioFeatures($tracks->implode(','));
6260

63-
foreach ($request->audio_features as $trackInfo) {
64-
if ($trackInfo == null) continue;
61+
foreach($request->audio_features as $trackInfo) {
62+
if($trackInfo == null)
63+
continue;
6564
try {
6665
SpotifyTrack::where('track_id', $trackInfo->id)->update(
6766
[
@@ -78,11 +77,11 @@ public function handle()
7877
'bpm' => $trackInfo->tempo
7978
]
8079
);
81-
} catch (\Exception $e) {
80+
} catch(Exception $e) {
8281
report($e);
8382
}
8483
}
85-
} catch (SpotifyAPIException $e) {
84+
} catch(SpotifyAPIException $e) {
8685
report($e);
8786
}
8887
return 0;

app/Console/Commands/Spotify_PlaylistRefresh.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
use App\User;
77
use App\UserSettings;
88
use Illuminate\Console\Command;
9+
use Exception;
910

10-
class Spotify_PlaylistRefresh extends Command
11-
{
11+
class Spotify_PlaylistRefresh extends Command {
1212

1313
/**
1414
* The name and signature of the console command.
@@ -29,23 +29,21 @@ class Spotify_PlaylistRefresh extends Command
2929
*
3030
* @return void
3131
*/
32-
public function __construct()
33-
{
32+
public function __construct() {
3433
parent::__construct();
3534
}
3635

3736
/**
3837
* Execute the console command
3938
*/
40-
public function handle()
41-
{
39+
public function handle() {
4240
$users = UserSettings::where('name', 'spotify_createOldPlaylist')->where('val', '1')->select('user_id')->get();
43-
foreach ($users as $user) {
41+
foreach($users as $user) {
4442
try {
4543
$user = User::find($user->user_id);
4644

4745
SpotifyController::generateLostPlaylist($user);
48-
} catch (\Exception $e) {
46+
} catch(Exception $e) {
4947
echo $e->getMessage();
5048
}
5149
}

app/Console/Commands/Spotify_TokenRefresh.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Carbon\Carbon;
88
use Illuminate\Console\Command;
99
use Illuminate\Support\Facades\Log;
10+
use Exception;
1011

1112
class Spotify_TokenRefresh extends Command {
1213

@@ -41,7 +42,7 @@ public function handle(): int {
4142
'spotify_lastRefreshed' => Carbon::now()
4243
]);
4344

44-
} catch(\Exception $e) {
45+
} catch(Exception $e) {
4546
report($e);
4647
dump($e->getMessage());
4748
}

app/Console/Commands/Telegram_SetWebhook.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
use Illuminate\Console\Command;
66
use Telegram\Bot\Laravel\Facades\Telegram;
77

8-
class Telegram_SetWebhook extends Command
9-
{
8+
class Telegram_SetWebhook extends Command {
109
/**
1110
* The name and signature of the console command.
1211
*
@@ -26,8 +25,7 @@ class Telegram_SetWebhook extends Command
2625
*
2726
* @return void
2827
*/
29-
public function __construct()
30-
{
28+
public function __construct() {
3129
parent::__construct();
3230
}
3331

@@ -36,8 +34,7 @@ public function __construct()
3634
*
3735
* @return mixed
3836
*/
39-
public function handle()
40-
{
37+
public function handle() {
4138
$url = strtr(':url/:token/webhook', [
4239
':url' => config('app.url'),
4340
':token' => config('telegram.bots.mybot.token')

app/Console/Commands/Twitter_CheckUnfollows.php

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
use App\TwitterUnfollower;
1010
use Carbon\Carbon;
1111
use Illuminate\Console\Command;
12+
use Exception;
1213

13-
class Twitter_CheckUnfollows extends Command
14-
{
14+
class Twitter_CheckUnfollows extends Command {
1515
/**
1616
* The name and signature of the console command.
1717
*
@@ -31,8 +31,7 @@ class Twitter_CheckUnfollows extends Command
3131
*
3232
* @return void
3333
*/
34-
public function __construct()
35-
{
34+
public function __construct() {
3635
parent::__construct();
3736
}
3837

@@ -41,33 +40,32 @@ public function __construct()
4140
*
4241
* @return mixed
4342
*/
44-
public function handle()
45-
{
43+
public function handle() {
4644

47-
if (!config('app.twitter.crawling')) {
45+
if(!config('app.twitter.crawling')) {
4846
dump("Twitter crawling currently deactivated.");
4947
return;
5048
}
5149

5250
$toCheck = TwitterFollower::orderBy('updated_at', 'asc')->limit($this->argument('limit'))->get();
53-
foreach ($toCheck as $relationship) {
51+
foreach($toCheck as $relationship) {
5452
try {
5553
$sl_profile = SocialLoginProfile::where('twitter_id', $relationship->followed_id)->where('twitter_token', '<>', null)->first();
56-
if ($sl_profile == null) {
54+
if($sl_profile == null) {
5755
dump("No SL Profile " . $relationship->followed->screen_name);
5856
continue;
5957
}
6058

6159
$connection = TwitterApiController::getNewConnection($sl_profile);
62-
if (!TwitterApiController::canRequest($sl_profile, 'users/show', 900)) {
60+
if(!TwitterApiController::canRequest($sl_profile, 'users/show', 900)) {
6361
dump("No Requests " . $sl_profile->twitter_id);
6462
continue;
6563
}
6664

6765
$follower = $connection->get('users/show', ['user_id' => $relationship->follower_id]);
68-
if (isset($follower->errors)) {
69-
foreach ($follower->errors as $error) {
70-
if ($error->code == 50 || $error->code == 63) { //not found, suspendet
66+
if(isset($follower->errors)) {
67+
foreach($follower->errors as $error) {
68+
if($error->code == 50 || $error->code == 63) { //not found, suspendet
7169
dump("User not found -> handle Unfollow");
7270
$relationship->delete();
7371

@@ -83,16 +81,16 @@ public function handle()
8381
}
8482
}
8583

86-
if (!TwitterApiController::canRequest($sl_profile, 'friendships/lookup', 15)) {
84+
if(!TwitterApiController::canRequest($sl_profile, 'friendships/lookup', 15)) {
8785
dump("No Requests " . $sl_profile->twitter_id);
8886
continue;
8987
}
9088

9189
$result = $connection->get("friendships/lookup", ['user_id' => $relationship->follower_id]); //TODO: multiple requests
9290
TwitterApiController::saveRequest($sl_profile, 'friendships/lookup');
9391

94-
foreach ($result as $real_relationship) {
95-
if (!isset($real_relationship->connections)) {
92+
foreach($result as $real_relationship) {
93+
if(!isset($real_relationship->connections)) {
9694
dump($real_relationship);
9795
dump("No Connection array?");
9896
continue;
@@ -101,7 +99,7 @@ public function handle()
10199
//$following = in_array('following', $real_relationship->connections);
102100
$followed_by = in_array('followed_by', $real_relationship->connections);
103101

104-
if (!$followed_by) {
102+
if(!$followed_by) {
105103
dump("User " . $relationship->follower->screen_name . ' hat ' . $relationship->followed->screen_name . ' entfolgt.');
106104
$relationship->delete();
107105

@@ -118,7 +116,7 @@ public function handle()
118116
$relationship->update();
119117
}
120118
}
121-
} catch (\Exception $e) {
119+
} catch(Exception $e) {
122120
dump($e);
123121
report($e);
124122
}

0 commit comments

Comments
 (0)