Skip to content
This repository has been archived by the owner on Jul 9, 2019. It is now read-only.

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie authored and StyleCIBot committed Apr 25, 2017
1 parent 7a3aa50 commit 58e382f
Show file tree
Hide file tree
Showing 21 changed files with 79 additions and 138 deletions.
4 changes: 1 addition & 3 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
*
* This file is part of reflar/gamification.
*
* Copyright (c) ReFlar.
Expand All @@ -9,7 +8,6 @@
*
* For the full copyright and license information, please view the license.md
* file that was distributed with this source code.
*
*/

namespace Reflar\gamification;
Expand All @@ -23,4 +21,4 @@
$events->subscribe(Listeners\AddClientAssets::class);
$events->subscribe(Listeners\SaveVotesToDatabase::class);
$events->subscribe(Listeners\FilterDiscussionListByHotness::class);
};
};
4 changes: 0 additions & 4 deletions migrations/2017_04_09_224815_create_posts_votes_table.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
*
* This file is part of reflar/gamification.
*
* Copyright (c) ReFlar.
Expand All @@ -9,10 +8,7 @@
*
* For the full copyright and license information, please view the license.md
* file that was distributed with this source code.
*
*/


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

Expand Down
3 changes: 0 additions & 3 deletions migrations/2017_04_09_225024_add_votes_to_users.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
*
* This file is part of reflar/gamification.
*
* Copyright (c) ReFlar.
Expand All @@ -9,9 +8,7 @@
*
* For the full copyright and license information, please view the license.md
* file that was distributed with this source code.
*
*/

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

Expand Down
3 changes: 0 additions & 3 deletions migrations/2017_04_24_094425_add_hotness_to_discussions.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
*
* This file is part of reflar/gamification.
*
* Copyright (c) ReFlar.
Expand All @@ -9,9 +8,7 @@
*
* For the full copyright and license information, please view the license.md
* file that was distributed with this source code.
*
*/

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

Expand Down
17 changes: 8 additions & 9 deletions src/Api/Controllers/ConvertLikesController.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
*
* This file is part of reflar/gamification.
*
* Copyright (c) ReFlar.
Expand All @@ -9,23 +8,21 @@
*
* For the full copyright and license information, please view the license.md
* file that was distributed with this source code.
*
*/

namespace Reflar\gamification\Api\Controllers;

use Flarum\Core\Access\AssertPermissionTrait;
use Flarum\Core\Discussion;
use Flarum\Http\Controller\ControllerInterface;
use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\Core\Discussion;
use Psr\Http\Message\ServerRequestInterface;
use Reflar\gamification\Likes;
use Reflar\gamification\Repository\Gamification;
use Zend\Diactoros\Response\JsonResponse;

class ConvertLikesController implements ControllerInterface
{

use AssertPermissionTrait;

/**
Expand All @@ -40,7 +37,7 @@ class ConvertLikesController implements ControllerInterface

/**
* @param SettingsRepositoryInterface $settings
* @param Gamification $gamification
* @param Gamification $gamification
*/
public function __construct(SettingsRepositoryInterface $settings, Gamification $gamification)
{
Expand All @@ -50,6 +47,7 @@ public function __construct(SettingsRepositoryInterface $settings, Gamification

/**
* @param ServerRequestInterface $request
*
* @return int
*/
public function handle(ServerRequestInterface $request)
Expand All @@ -67,15 +65,16 @@ public function handle(ServerRequestInterface $request)
$this->gamification->convertLike($like->post_id, $like->user_id, $actor);
$counter++;
}

$discussions = Discussion::all();

foreach ($discussions as $discussion) {
$this->gamification->calculateHotness($discussion);
}

$this->settings->set('reflar.gamification.convertedLikes', $counter);

return new JsonResponse($counter, 200);
}
}
}
}
14 changes: 6 additions & 8 deletions src/Api/Controllers/ListTopThreeController.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
*
* This file is part of reflar/gamification.
*
* Copyright (c) ReFlar.
Expand All @@ -9,23 +8,20 @@
*
* For the full copyright and license information, please view the license.md
* file that was distributed with this source code.
*
*/

namespace Reflar\gamification\Api\Controllers;

use Flarum\Api\Controller\AbstractCollectionController;
use Flarum\Core\Post\Floodgate;
use Psr\Http\Message\ServerRequestInterface;
use Tobscure\JsonApi\Document;
use Reflar\gamification\Repository\Gamification;
use Reflar\gamificarion\Api\Serializers\TopThreeSerializer;
use Tobscure\JsonApi\Document;

class ListTopThreeController extends AbstractCollectionController
{

public $serializer = 'Flarum\Api\Serializer\UserSerializer';

/**
* @var Gamification
*/
Expand All @@ -47,13 +43,15 @@ public function __construct(Gamification $gamification, Floodgate $floodgate)

/**
* @param ServerRequestInterface $request
*
* @return mixed
*/
protected function data(ServerRequestInterface $request, Document $document)
{
if (! $request->getAttribute('bypassFloodgate')) {
if (!$request->getAttribute('bypassFloodgate')) {
$this->floodgate->assertNotFlooding($request->getAttribute('actor'));
}

return $this->gamification->findTopThree();
}
}
}
9 changes: 3 additions & 6 deletions src/Commands/Vote.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
*
* This file is part of reflar/gamification.
*
* Copyright (c) ReFlar.
Expand All @@ -9,12 +8,10 @@
*
* For the full copyright and license information, please view the license.md
* file that was distributed with this source code.
*
*/

namespace Reflar\gamification\Commands;


class Vote
{
/**.
Expand All @@ -33,8 +30,8 @@ class Vote
public $type;

/**
* @param int $post_id
* @param User $actor
* @param int $post_id
* @param User $actor
* @param string $type
*/
public function __construct($post_id, User $actor, $type)
Expand All @@ -43,4 +40,4 @@ public function __construct($post_id, User $actor, $type)
$this->actor = $actor;
$this->type = $type;
}
}
}
4 changes: 1 addition & 3 deletions src/Commands/VoteHandler.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
*
* This file is part of reflar/gamification.
*
* Copyright (c) ReFlar.
Expand All @@ -9,7 +8,6 @@
*
* For the full copyright and license information, please view the license.md
* file that was distributed with this source code.
*
*/

namespace Reflar\gamification\Commands;
Expand Down Expand Up @@ -45,4 +43,4 @@ public function handle(Vote $command)
$this->gamification->downvote($postId, $actor);
}
}
}
}
4 changes: 1 addition & 3 deletions src/Events/PostWasDownvoted.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
*
* This file is part of reflar/gamification.
*
* Copyright (c) ReFlar.
Expand All @@ -9,7 +8,6 @@
*
* For the full copyright and license information, please view the license.md
* file that was distributed with this source code.
*
*/

namespace Reflar\gamification\Events;
Expand Down Expand Up @@ -45,4 +43,4 @@ public function __construct(Post $post, User $user, User $actor)
$this->user = $user;
$this->actor = $actor;
}
}
}
4 changes: 1 addition & 3 deletions src/Events/PostWasUpvoted.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
*
* This file is part of reflar/gamification.
*
* Copyright (c) ReFlar.
Expand All @@ -9,7 +8,6 @@
*
* For the full copyright and license information, please view the license.md
* file that was distributed with this source code.
*
*/

namespace Reflar\gamification\Events;
Expand Down Expand Up @@ -45,4 +43,4 @@ public function __construct(Post $post, User $user, User $actor)
$this->user = $user;
$this->actor = $actor;
}
}
}
7 changes: 2 additions & 5 deletions src/Gambit/HotGambit.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
*
* This file is part of reflar/gamification.
*
* Copyright (c) ReFlar.
Expand All @@ -9,14 +8,12 @@
*
* For the full copyright and license information, please view the license.md
* file that was distributed with this source code.
*
*/

namespace Reflar\gamification\Gambit;

use Flarum\Core\Search\AbstractRegexGambit;
use Flarum\Core\Search\AbstractSearch;
use Illuminate\Database\Query\Expression;

class HotGambit extends AbstractRegexGambit
{
Expand All @@ -27,11 +24,11 @@ class HotGambit extends AbstractRegexGambit

/**
* @param AbstractSearch $search
* @param array $matches
* @param array $matches
* @param $negate
*/
protected function conditions(AbstractSearch $search, array $matches, $negate)
{
$search->getQuery()->orderBy('hotness', 'desc');
}
}
}
4 changes: 1 addition & 3 deletions src/Likes.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
*
* This file is part of reflar/gamification.
*
* Copyright (c) ReFlar.
Expand All @@ -9,7 +8,6 @@
*
* For the full copyright and license information, please view the license.md
* file that was distributed with this source code.
*
*/

namespace Reflar\gamification;
Expand All @@ -19,4 +17,4 @@
class Likes extends AbstractModel
{
protected $table = 'posts_likes';
}
}
10 changes: 4 additions & 6 deletions src/Listeners/AddApiAttributes.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
*
* This file is part of reflar/gamification.
*
* Copyright (c) ReFlar.
Expand All @@ -9,7 +8,6 @@
*
* For the full copyright and license information, please view the license.md
* file that was distributed with this source code.
*
*/

namespace Reflar\gamification\Listeners;
Expand Down Expand Up @@ -39,12 +37,12 @@ public function configureApiRoutes(ConfigureApiRoutes $event)
$event->post('/reflar/gamification/convert', 'reflar.gamification.convert', ConvertLikesController::class);
// $event->get('/rankings', 'rankings', ListTopThreeController::class);
}
/**

/*
* @param ConfigureForumRoutes $event
*/
/** public function configureForumRoutes(ConfigureForumRoutes $event)
/* public function configureForumRoutes(ConfigureForumRoutes $event)
{
$event->get('/rankings', 'rankings');
} **/
}
}
Loading

0 comments on commit 58e382f

Please sign in to comment.