Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
dsevillamartin authored and StyleCIBot committed Jan 13, 2019
1 parent a568123 commit e8b37fc
Show file tree
Hide file tree
Showing 18 changed files with 76 additions and 58 deletions.
6 changes: 3 additions & 3 deletions extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
/*
* This file is part of fof/links.
*
* Copyright (c) 2018 FriendsOfFlarum.
* Copyright (c) 2019 FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Flarum\Extend;
use FoF\Links\Listener;
use FoF\Links\Api\Controller;
use FoF\Links\Listener;
use Illuminate\Contracts\Events\Dispatcher;

return [
Expand All @@ -32,5 +32,5 @@

function (Dispatcher $events) {
$events->subscribe(Listener\AddLinksRelationship::class);
}
},
];
9 changes: 6 additions & 3 deletions migrations/2016_02_13_000000_create_links_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of fof/links.
*
* Copyright (c) 2018 FriendsOfFlarum.
* Copyright (c) 2019 FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -12,9 +12,12 @@
use Flarum\Database\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;

return [
'up' => function (Builder $schema) {
if ($schema->hasTable('links')) return;
if ($schema->hasTable('links')) {
return;
}

$schema->create('links', function (Blueprint $table) use ($schema) {
$table->increments('id');
Expand All @@ -30,5 +33,5 @@
},
'down' => function (Builder $schema) {
$schema->dropIfExists('links');
}
},
];
15 changes: 13 additions & 2 deletions migrations/2016_04_19_065618_change_links_columns.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
<?php

/*
* This file is part of fof/links.
*
* Copyright (c) 2019 FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;

return [
'up' => function (Builder $schema) {
if ($schema->hasColumns('links', ['is_internal', 'is_newtab'])) return;
if ($schema->hasColumns('links', ['is_internal', 'is_newtab'])) {
return;
}

$schema->table('links', function (Blueprint $table) {
$table->dropColumn('type');
Expand All @@ -24,5 +35,5 @@
$table->dropColumn('is_internal');
$table->dropColumn('is_newtab');
});
}
},
];
4 changes: 2 additions & 2 deletions src/Api/Controller/CreateLinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of fof/links.
*
* Copyright (c) 2018 FriendsOfFlarum.
* Copyright (c) 2019 FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -21,7 +21,7 @@
class CreateLinkController extends AbstractCreateController
{
/**
* @inheritdoc
* {@inheritdoc}
*/
public $serializer = LinkSerializer::class;

Expand Down
4 changes: 1 addition & 3 deletions src/Api/Controller/DeleteLinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
/*
* This file is part of fof/links.
*
* Copyright (c) 2018 FriendsOfFlarum.
* Copyright (c) 2019 FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FoF\Links\Api\Controller;

;

use Flarum\Api\Controller\AbstractDeleteController;
use FoF\Links\Command\DeleteLink;
use Illuminate\Contracts\Bus\Dispatcher;
Expand Down
3 changes: 1 addition & 2 deletions src/Api/Controller/OrderLinksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of fof/links.
*
* Copyright (c) 2018 FriendsOfFlarum.
* Copyright (c) 2019 FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -12,7 +12,6 @@
namespace FoF\Links\Api\Controller;

use Flarum\User\AssertPermissionTrait;
use Flarum\Http\Controller\ControllerInterface;
use FoF\Links\Link;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand Down
4 changes: 2 additions & 2 deletions src/Api/Controller/UpdateLinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of fof/links.
*
* Copyright (c) 2018 FriendsOfFlarum.
* Copyright (c) 2019 FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -21,7 +21,7 @@
class UpdateLinkController extends AbstractShowController
{
/**
* @inheritdoc
* {@inheritdoc}
*/
public $serializer = LinkSerializer::class;

Expand Down
3 changes: 1 addition & 2 deletions src/Api/Serializer/LinkSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of fof/links.
*
* Copyright (c) 2018 FriendsOfFlarum.
* Copyright (c) 2019 FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -12,7 +12,6 @@
namespace FoF\Links\Api\Serializer;

use Flarum\Api\Serializer\AbstractSerializer;
use Flarum\Api\Serializer\DiscussionSerializer;

class LinkSerializer extends AbstractSerializer
{
Expand Down
6 changes: 3 additions & 3 deletions src/Command/CreateLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of fof/links.
*
* Copyright (c) 2018 FriendsOfFlarum.
* Copyright (c) 2019 FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -30,8 +30,8 @@ class CreateLink
public $data;

/**
* @param User $actor The user performing the action.
* @param array $data The attributes of the new link.
* @param User $actor The user performing the action.
* @param array $data The attributes of the new link.
*/
public function __construct(User $actor, array $data)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Command/CreateLinkHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of fof/links.
*
* Copyright (c) 2018 FriendsOfFlarum.
* Copyright (c) 2019 FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down Expand Up @@ -34,6 +34,7 @@ public function __construct(LinkValidator $validator)

/**
* @param CreateLink $command
*
* @return Link
*/
public function handle(CreateLink $command)
Expand Down
10 changes: 5 additions & 5 deletions src/Command/DeleteLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of fof/links.
*
* Copyright (c) 2018 FriendsOfFlarum.
* Copyright (c) 2019 FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down Expand Up @@ -38,10 +38,10 @@ class DeleteLink
public $data;

/**
* @param int $linkId The ID of the link to delete.
* @param User $actor The user performing the action.
* @param array $data Any other link input associated with the action. This
* is unused by default, but may be used by extensions.
* @param int $linkId The ID of the link to delete.
* @param User $actor The user performing the action.
* @param array $data Any other link input associated with the action. This
* is unused by default, but may be used by extensions.
*/
public function __construct($linkId, User $actor, array $data = [])
{
Expand Down
6 changes: 4 additions & 2 deletions src/Command/DeleteLinkHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of fof/links.
*
* Copyright (c) 2018 FriendsOfFlarum.
* Copyright (c) 2019 FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down Expand Up @@ -33,8 +33,10 @@ public function __construct(LinkRepository $links)

/**
* @param DeleteLink $command
* @return \FoF\Links\Link
*
* @throws \Flarum\User\Exception\PermissionDeniedException
*
* @return \FoF\Links\Link
*/
public function handle(DeleteLink $command)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Command/EditLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of fof/links.
*
* Copyright (c) 2018 FriendsOfFlarum.
* Copyright (c) 2019 FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down Expand Up @@ -37,9 +37,9 @@ class EditLink
public $data;

/**
* @param int $linkId The ID of the link to edit.
* @param User $actor The user performing the action.
* @param array $data The attributes to update on the link.
* @param int $linkId The ID of the link to edit.
* @param User $actor The user performing the action.
* @param array $data The attributes to update on the link.
*/
public function __construct($linkId, User $actor, array $data)
{
Expand Down
8 changes: 5 additions & 3 deletions src/Command/EditLinkHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of fof/links.
*
* Copyright (c) 2018 FriendsOfFlarum.
* Copyright (c) 2019 FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down Expand Up @@ -31,7 +31,7 @@ class EditLinkHandler

/**
* @param LinkRepository $links
* @param LinkValidator $validator
* @param LinkValidator $validator
*/
public function __construct(LinkRepository $links, LinkValidator $validator)
{
Expand All @@ -41,8 +41,10 @@ public function __construct(LinkRepository $links, LinkValidator $validator)

/**
* @param EditLink $command
* @return \FoF\Links\Link
*
* @throws \Flarum\User\Exception\PermissionDeniedException
*
* @return \FoF\Links\Link
*/
public function handle(EditLink $command)
{
Expand Down
21 changes: 11 additions & 10 deletions src/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of fof/links.
*
* Copyright (c) 2018 FriendsOfFlarum.
* Copyright (c) 2019 FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -24,28 +24,29 @@ class Link extends AbstractModel
* @var array
*/
protected $casts = [
'id' => 'integer',
'id' => 'integer',
'is_internal' => 'boolean',
'is_newtab' => 'boolean',
'is_newtab' => 'boolean',
];

/**
* Create a new link.
*
* @param string $name
* @param string $url
* @param bool $isInternal
* @param bool $isNewtab
* @param bool $isInternal
* @param bool $isNewtab
*
* @return static
*/
public static function build($name, $url, $isInternal, $isNewtab)
{
$link = new static;
$link = new static();

$link->title = $name;
$link->url = $url;
$link->is_internal = (bool) $isInternal;
$link->is_newtab = (bool) $isNewtab;
$link->title = $name;
$link->url = $url;
$link->is_internal = (bool) $isInternal;
$link->is_newtab = (bool) $isNewtab;

return $link;
}
Expand Down
14 changes: 8 additions & 6 deletions src/LinkRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of fof/links.
*
* Copyright (c) 2018 FriendsOfFlarum.
* Copyright (c) 2019 FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -12,27 +12,29 @@
namespace FoF\Links;

use Flarum\User\User;
use Illuminate\Database\Eloquent\Builder;

class LinkRepository
{
/**
* Find a link by ID
* Find a link by ID.
*
* @param int $id
* @param int $id
* @param User $actor
* @return Link
*
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
*
* @return Link
*/
public function findOrFail($id, User $actor = null)
{
return Link::where('id', $id)->firstOrFail();
}

/**
* Get all links
* Get all links.
*
* @param User|null $user
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public function all()
Expand Down
Loading

0 comments on commit e8b37fc

Please sign in to comment.