Fixed some style errors; Updated the PHP_CodeSniffer rules to be better
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Gregory Ballantine 2022-03-08 12:23:41 -05:00
parent c4afe6f08e
commit 2b1ec13f53
2 changed files with 29 additions and 23 deletions

View File

@ -2,26 +2,32 @@
<ruleset name="PHP_CodeSniffer"> <ruleset name="PHP_CodeSniffer">
<description>PHPCS configuration file.</description> <description>PHPCS configuration file.</description>
<arg name="basepath" value="." /> <arg name="basepath" value="." />
<arg name="extensions" value="php" /> <arg name="extensions" value="php" />
<arg name="colors" /> <arg name="colors" />
<arg name="cache" value=".phpcs-cache" /> <arg name="cache" value=".phpcs-cache" />
<arg value="p" /> <arg value="p" />
<arg value="s" /> <arg value="s" />
<!-- Check PHP files in the src/ directory --> <!-- Check PHP files in the src/ directory -->
<file>src/</file> <file>src/</file>
<!-- Our base rule: set to PSR12--> <!-- Our base rule: set to PSR12-->
<rule ref="PSR12"/> <rule ref="PSR12">
<exclude name="PSR2.Classes.ClassDeclaration.OpenBraceNewLine" />
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine" />
</rule>
<!-- Set indent size to 2 --> <!-- Some custom rules -->
<rule ref="Generic.WhiteSpace.ScopeIndent"> <rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie" />
<rule ref="Generic.Classes.OpeningBraceSameLine" />
<!-- Set indent size to 2 -->
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties> <properties>
<property name="indent" value="2" /> <property name="indent" value="2" />
</properties> </properties>
</rule> </rule>
</ruleset> </ruleset>

View File

@ -15,7 +15,7 @@ use Pigeon\Models\Video;
$config = new Config('config/config.yaml'); $config = new Config('config/config.yaml');
// create Eloquent connection object // create Eloquent connection object
$capsule = new Capsule; $capsule = new Capsule();
$capsule->addConnection([ $capsule->addConnection([
'driver' => 'sqlite', 'driver' => 'sqlite',
'database' => $config->get('pigeon.db_path'), 'database' => $config->get('pigeon.db_path'),
@ -36,12 +36,12 @@ $uploads = $youtube->getPlaylistItemsByPlaylistId($config->get('youtube.uploads_
// create Video model objects with the above uploads // create Video model objects with the above uploads
foreach ($uploads as $u) { foreach ($uploads as $u) {
$video = new Video; $video = new Video();
$video->video_id = $u->contentDetails->videoId; $video->video_id = $u->contentDetails->videoId;
$video->published_at = date($u->contentDetails->videoPublishedAt); $video->published_at = date($u->contentDetails->videoPublishedAt);
// create the table entry if it doesn't already exist // create the table entry if it doesn't already exist
Video::where('video_id', $video->video_id)->firstOr(function() use ($video) { Video::where('video_id', $video->video_id)->firstOr(function () use ($video) {
$video->save(); $video->save();
}); });
} }
@ -63,7 +63,7 @@ $loop->addPeriodicTimer($config->get('pigeon.check_interval') * 60, function ()
$uploadDetails = $uploads[0]->contentDetails; $uploadDetails = $uploads[0]->contentDetails;
// search for the latest video in the DB // search for the latest video in the DB
Video::where('video_id', $uploadDetails->videoId)->firstOr(function() use ($discord, $config, $uploadDetails) { Video::where('video_id', $uploadDetails->videoId)->firstOr(function () use ($discord, $config, $uploadDetails) {
$latest_url = "https://youtu.be/$uploadDetails->videoId"; $latest_url = "https://youtu.be/$uploadDetails->videoId";
$message_text = str_replace('{link}', $latest_url, $config->get('discord.message_template')); $message_text = str_replace('{link}', $latest_url, $config->get('discord.message_template'));
@ -75,7 +75,7 @@ $loop->addPeriodicTimer($config->get('pigeon.check_interval') * 60, function ()
}); });
// add the video to the DB // add the video to the DB
$video = new Video; $video = new Video();
$video->video_id = $uploadDetails->videoId; $video->video_id = $uploadDetails->videoId;
$video->published_at = date($uploadDetails->videoPublishedAt); $video->published_at = date($uploadDetails->videoPublishedAt);
$video->save(); $video->save();