Skip to content

Commit

Permalink
Add pint
Browse files Browse the repository at this point in the history
  • Loading branch information
christophrumpel committed May 21, 2024
1 parent 8edf0f9 commit cc6fa9d
Show file tree
Hide file tree
Showing 52 changed files with 247 additions and 777 deletions.
38 changes: 24 additions & 14 deletions .github/workflows/format-php.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
name: Format (PHP)
name: Format Code

on:
push:
branches: [ main ]
paths:
- '**.php'
on: [ push ]

jobs:
php-cs-fixer:
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [ 8.3 ]

steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: json, dom, curl, libxml, mbstring
coverage: none

- name: Install
run: composer install
- name: Install Pint
run: composer global require laravel/pint

- name: Run php-cs-fixer
run: ./vendor/bin/php-cs-fixer fix
- name: Run Pint
run: pint

- uses: stefanzweifel/git-auto-commit-action@v4
- name: Commit linted files
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Apply php-cs-fixer changes
commit_message: "Fixes coding style"
185 changes: 0 additions & 185 deletions .php-cs-fixer.php

This file was deleted.

1 change: 1 addition & 0 deletions app/Actions/UpdateStreamAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\Stream;
use App\Services\YouTube\StreamData;

use function tap;

class UpdateStreamAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function handle(): int

if (is_null($streamData)) {
$stream->update([
'status' => StreamData::STATUS_DELETED,
'status' => StreamData::STATUS_DELETED,
'hidden_at' => Carbon::now(),
]);

Expand Down
3 changes: 2 additions & 1 deletion app/Livewire/ImportYouTubeChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
class ImportYouTubeChannel extends Component
{
public string $youTubeChannelId = '';

public string $languageCode = 'en';

public function getName(): string
Expand All @@ -37,7 +38,7 @@ public function importChannel(): void

dispatch(new ImportYoutubeChannelStreamsJob($this->youTubeChannelId, $this->languageCode));

session()->flash('channel-message', 'Channel "' . $this->youTubeChannelId . '" was added successfully.');
session()->flash('channel-message', 'Channel "'.$this->youTubeChannelId.'" was added successfully.');

$this->reset(['youTubeChannelId', 'languageCode']);
}
Expand Down
1 change: 1 addition & 0 deletions app/Livewire/ImportYouTubeLiveStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
class ImportYouTubeLiveStream extends Component
{
public string $youTubeId = '';

public string $language = 'en';

public function render(): View
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function scopeWithApprovedAndFinishedStreams(Builder $query): Builder
return $query->whereHas('streams', function(Builder $query) {
/** @var Builder<Stream> $query */
$query->approved()
->finished();
->finished();
});
}

Expand Down
26 changes: 13 additions & 13 deletions app/Models/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function scopeUpcoming(Builder $query): Builder
public function scopeUpcomingOrLive(Builder $query): Builder
{
return $query->where('status', StreamData::STATUS_LIVE)
->orWhere(function (Builder $query) {
->orWhere(function(Builder $query) {
/* @phpstan-ignore-next-line */
return $query->upcoming();
});
Expand Down Expand Up @@ -177,11 +177,11 @@ public function scopeScheduledTimeNotPassed(Builder $query): Builder

public function scopeSearch(Builder $query, ?string $search): Builder
{
return $query->when($search, function (Builder $builder, ?string $search) {
$builder->where(function (Builder $query) use ($search) {
return $query->when($search, function(Builder $builder, ?string $search) {
$builder->where(function(Builder $query) use ($search) {
$query
->where('title', 'like', "%$search%")
->orWhereHas('channel', function ($query) use ($search) {
->orWhereHas('channel', function($query) use ($search) {
$query->where('name', 'like', "%$search%");
});
});
Expand All @@ -198,16 +198,16 @@ public function scopeByStreamer(Builder $query, ?string $streamerHashid): Builde

return $query->when(
$channelId,
fn(Builder $builder, ?string $streamerHashid) => $builder->where(fn(Builder $query) => $query->where('channel_id', $channelId))
fn (Builder $builder, ?string $streamerHashid) => $builder->where(fn (Builder $query) => $query->where('channel_id', $channelId))
);
}

public function toFeedItem(): FeedItem
{
return FeedItem::create()
->id((string)$this->id)
->id((string) $this->id)
->title($this->title)
->summary((string)$this->description)
->summary((string) $this->description)
->updated($this->updated_at ?? now())
->link($this->url())
->authorName($this->channel()->first(['id', 'name'])?->name ?? '');
Expand All @@ -228,8 +228,8 @@ public function toCalendarItem(): Event
$this->title,
$this->channel?->name,
$this->url(),
Str::of((string)$this->description)
->whenNotEmpty(fn(Stringable $description) => $description->prepend(str_repeat('-', 15) . PHP_EOL))
Str::of((string) $this->description)
->whenNotEmpty(fn (Stringable $description) => $description->prepend(str_repeat('-', 15).PHP_EOL))
->remove("\r"),
]))
->startsAt($this->scheduled_start_time)
Expand Down Expand Up @@ -275,20 +275,20 @@ public function isApproved(): bool

public function duration(): Attribute
{
return Attribute::get(function (): ?string {
return Attribute::get(function(): ?string {
if (is_null($this->actual_end_time)) {
return null;
}

$startTime = $this->actual_start_time ?? $this->scheduled_start_time;

return (int)$startTime->diffInHours($this->actual_end_time) . 'h ' . $startTime->diff($this->actual_end_time)->format('%i') . 'm';
return (int) $startTime->diffInHours($this->actual_end_time).'h '.$startTime->diff($this->actual_end_time)->format('%i').'m';
});
}

public function startForHumans(): Attribute
{
return Attribute::get(function (): string {
return Attribute::get(function(): string {
if ($this->actual_start_time) {
return "Started {$this->actual_start_time->diffForHumans()}";
}
Expand All @@ -303,6 +303,6 @@ public function startForHumans(): Attribute

public function startForRobots(): Attribute
{
return Attribute::get(fn() => $this->actual_start_time?->toIso8601String() ?? $this->scheduled_start_time->toIso8601String());
return Attribute::get(fn () => $this->actual_start_time?->toIso8601String() ?? $this->scheduled_start_time->toIso8601String());
}
}
1 change: 0 additions & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class User extends Authenticatable
use HasFactory;
use Notifiable;


protected $fillable = [
'name',
'email',
Expand Down
Loading

0 comments on commit cc6fa9d

Please sign in to comment.