Fixed some style errors; Updated the PHP_CodeSniffer rules to be better
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
c4afe6f08e
commit
2b1ec13f53
42
phpcs.xml
42
phpcs.xml
@ -1,27 +1,33 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
<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" />
|
||||||
<properties>
|
<rule ref="Generic.Classes.OpeningBraceSameLine" />
|
||||||
<property name="indent" value="2" />
|
<!-- Set indent size to 2 -->
|
||||||
</properties>
|
<rule ref="Generic.WhiteSpace.ScopeIndent">
|
||||||
</rule>
|
<properties>
|
||||||
|
<property name="indent" value="2" />
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
@ -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();
|
||||||
|
Loading…
Reference in New Issue
Block a user