Skip to content

Commit c917ba5

Browse files
committed
Apply fixes from StyleCI
1 parent f5c24a4 commit c917ba5

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

src/Extend/LinksOverride.php

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of fof/links.
5+
*
6+
* Copyright (c) FriendsOfFlarum.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace FoF\Links\Extend;
413

514
use Flarum\Extend\ExtenderInterface;
@@ -24,18 +33,21 @@ class LinksOverride implements ExtenderInterface
2433
* that will return an array of LinkDefinition objects.
2534
*
2635
* @param LinkDefinition[]|string $links
36+
*
2737
* @return $this
2838
*/
2939
public function addLinks(array|string $links): self
3040
{
3141
$this->links = $links;
42+
3243
return $this;
3344
}
3445

3546
/**
3647
* Add a single link.
3748
*
3849
* @param LinkDefinition $link
50+
*
3951
* @return $this
4052
*/
4153
public function addLink(LinkDefinition $link): self
@@ -46,6 +58,7 @@ public function addLink(LinkDefinition $link): self
4658
// If a class string was already provided, override it with an array.
4759
$this->links = [$link];
4860
}
61+
4962
return $this;
5063
}
5164

@@ -54,7 +67,7 @@ public function addLink(LinkDefinition $link): self
5467
*
5568
* This binds the override links into the LinkRepository.
5669
*
57-
* @param Container $container
70+
* @param Container $container
5871
* @param Extension|null $extension
5972
*/
6073
public function extend(Container $container, ?Extension $extension = null): void

src/LinkRepository.php

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of fof/links.
5+
*
6+
* Copyright (c) FriendsOfFlarum.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace FoF\Links;
413

514
use Flarum\Locale\Translator;
@@ -54,7 +63,7 @@ public function queryVisibleTo(?User $actor = null): Builder
5463
/**
5564
* Find a link by ID.
5665
*
57-
* @param int $id
66+
* @param int $id
5867
* @param User|null $actor
5968
*
6069
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
@@ -66,6 +75,7 @@ public function findOrFail($id, ?User $actor = null): Link
6675
$query = Link::where('id', $id);
6776
/** @var Link $link */
6877
$link = $this->scopeVisibleTo($query, $actor)->firstOrFail();
78+
6979
return $link;
7080
}
7181

@@ -81,13 +91,14 @@ public function all(?User $user = null): EloquentCollection
8191
$query = Link::query();
8292
/** @var EloquentCollection<Link> $links */
8393
$links = $this->scopeVisibleTo($query, $user)->get();
94+
8495
return $links;
8596
}
8697

8798
/**
8899
* Scope a query to only include records that are visible to a user.
89100
*
90-
* @param Builder $query
101+
* @param Builder $query
91102
* @param User|null $user
92103
*
93104
* @return Builder
@@ -97,6 +108,7 @@ protected function scopeVisibleTo(Builder $query, ?User $user = null): Builder
97108
if ($user !== null) {
98109
$query->whereVisibleTo($user);
99110
}
111+
100112
return $query;
101113
}
102114

@@ -112,7 +124,7 @@ protected function scopeVisibleTo(Builder $query, ?User $user = null): Builder
112124
public function cacheKey(User $actor): string
113125
{
114126
if ($actor->isGuest()) {
115-
return self::$cacheKeyPrefix . self::$cacheGuestLinksKey;
127+
return self::$cacheKeyPrefix.self::$cacheGuestLinksKey;
116128
} else {
117129
throw new \InvalidArgumentException('Only guests can have cached links at this time.');
118130
}
@@ -137,8 +149,10 @@ public function getLinks(User $actor): EloquentCollection
137149
return $link->guest_only;
138150
});
139151
}
152+
140153
return new EloquentCollection($links->all());
141154
}
155+
142156
return $this->getLinksFromDatabase($actor);
143157
}
144158

@@ -167,6 +181,7 @@ public function getGuestLinks(User $actor): EloquentCollection
167181
} else {
168182
$links = $this->getLinksFromDatabase($actor);
169183
$this->cache->forever($this->cacheKey($actor), $links);
184+
170185
return $links;
171186
}
172187
}
@@ -190,7 +205,7 @@ protected function getLinksFromDatabase(User $actor): EloquentCollection
190205
*/
191206
public function clearLinksCache(): void
192207
{
193-
$this->cache->forget(self::$cacheKeyPrefix . self::$cacheGuestLinksKey);
208+
$this->cache->forget(self::$cacheKeyPrefix.self::$cacheGuestLinksKey);
194209
}
195210

196211
/**
@@ -233,6 +248,7 @@ protected function buildLinkFromDefinition(LinkDefinition $definition): Link
233248
$link->exists = true;
234249
$link->syncOriginal();
235250
$link->makeVisible('id');
251+
236252
return $link;
237253
}
238254
}

0 commit comments

Comments
 (0)