Skip to content

Commit

Permalink
Rename imported interfaces aliases suffixes from *Contract to *Interf…
Browse files Browse the repository at this point in the history
…ace (#178)

Rename imported interfaces aliases suffixes from *Contract to *Interface
antonkomarev authored Oct 4, 2020
1 parent 6334529 commit 526d12d
Showing 47 changed files with 311 additions and 303 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,12 @@ All notable changes to `laravel-love` will be documented in this file.

## [Unreleased]

## [8.6.1] - 2020-10-04

### Changed

- ([#178]) Rename imported interfaces aliases

## [8.6.0] - 2020-10-02

### Added
@@ -450,7 +456,8 @@ Follow [upgrade instructions](UPGRADING.md#from-v5-to-v6) to migrate database to

- Initial release

[Unreleased]: https://github.com/cybercog/laravel-love/compare/8.6.0...master
[Unreleased]: https://github.com/cybercog/laravel-love/compare/8.6.1...master
[8.6.1]: https://github.com/cybercog/laravel-love/compare/8.6.0...8.6.1
[8.6.0]: https://github.com/cybercog/laravel-love/compare/8.5.0...8.6.0
[8.5.0]: https://github.com/cybercog/laravel-love/compare/8.4.0...8.5.0
[8.4.0]: https://github.com/cybercog/laravel-love/compare/8.3.1...8.4.0
@@ -493,6 +500,7 @@ Follow [upgrade instructions](UPGRADING.md#from-v5-to-v6) to migrate database to
[1.1.1]: https://github.com/cybercog/laravel-love/compare/1.1.0...1.1.1
[1.1.0]: https://github.com/cybercog/laravel-love/compare/1.0.0...1.1.0

[#178]: https://github.com/cybercog/laravel-love/pull/178
[#177]: https://github.com/cybercog/laravel-love/pull/177
[#176]: https://github.com/cybercog/laravel-love/pull/176
[#165]: https://github.com/cybercog/laravel-love/pull/165
4 changes: 2 additions & 2 deletions contracts/Reactable/Exceptions/ReactableInvalid.php
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
namespace Cog\Contracts\Love\Reactable\Exceptions;

use Cog\Contracts\Love\Exceptions\LoveThrowable;
use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableContract;
use Cog\Contracts\Love\Reactable\Models\Reactable;
use RuntimeException;

final class ReactableInvalid extends RuntimeException implements
@@ -32,7 +32,7 @@ public static function notImplementInterface(string $type): self
{
return new self(sprintf(
'[%s] must implement `%s` contract.',
$type, ReactableContract::class
$type, Reactable::class
));
}
}
4 changes: 2 additions & 2 deletions contracts/Reacterable/Exceptions/ReacterableInvalid.php
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
namespace Cog\Contracts\Love\Reacterable\Exceptions;

use Cog\Contracts\Love\Exceptions\LoveThrowable;
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableContract;
use Cog\Contracts\Love\Reacterable\Models\Reacterable;
use RuntimeException;

final class ReacterableInvalid extends RuntimeException implements
@@ -32,7 +32,7 @@ public static function notImplementInterface(string $type): self
{
return new self(sprintf(
'[%s] must implement `%s` contract.',
$type, ReacterableContract::class
$type, Reacterable::class
));
}
}
10 changes: 5 additions & 5 deletions src/Console/Commands/Recount.php
Original file line number Diff line number Diff line change
@@ -14,12 +14,12 @@
namespace Cog\Laravel\Love\Console\Commands;

use Cog\Contracts\Love\Reactable\Exceptions\ReactableInvalid;
use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableContract;
use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableInterface;
use Cog\Laravel\Love\Reactant\Jobs\RebuildReactionAggregatesJob;
use Cog\Laravel\Love\Reactant\Models\Reactant;
use Cog\Laravel\Love\ReactionType\Models\ReactionType;
use Illuminate\Console\Command;
use Illuminate\Contracts\Bus\Dispatcher as DispatcherContract;
use Illuminate\Contracts\Bus\Dispatcher as DispatcherInterface;
use Illuminate\Database\Eloquent\Relations\Relation;
use Symfony\Component\Console\Input\InputOption;

@@ -59,7 +59,7 @@ protected function getOptions(
}

public function __construct(
DispatcherContract $dispatcher
DispatcherInterface $dispatcher
) {
parent::__construct();
$this->dispatcher = $dispatcher;
@@ -130,14 +130,14 @@ private function normalizeReactableModelType(
*/
private function reactableModelFromType(
string $modelType
): ReactableContract {
): ReactableInterface {
if (!class_exists($modelType)) {
$modelType = $this->findModelTypeInMorphMap($modelType);
}

$model = new $modelType();

if (!$model instanceof ReactableContract) {
if (!$model instanceof ReactableInterface) {
throw ReactableInvalid::notImplementInterface($modelType);
}

8 changes: 4 additions & 4 deletions src/Console/Commands/RegisterReactants.php
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
namespace Cog\Laravel\Love\Console\Commands;

use Cog\Contracts\Love\Reactable\Exceptions\ReactableInvalid;
use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableContract;
use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableInterface;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\Relation;
@@ -94,14 +94,14 @@ public function handle(): int
*/
private function reactableModelFromType(
string $modelType
): ReactableContract {
): ReactableInterface {
if (!class_exists($modelType)) {
$modelType = $this->findModelTypeInMorphMap($modelType);
}

$model = new $modelType();

if (!$model instanceof ReactableContract) {
if (!$model instanceof ReactableInterface) {
throw ReactableInvalid::notImplementInterface($modelType);
}

@@ -149,7 +149,7 @@ private function normalizeIds(array $modelIds): array
* @return Collection
*/
private function collectModels(
ReactableContract $reactableModel,
ReactableInterface $reactableModel,
array $modelIds
): Collection {
$query = $reactableModel
8 changes: 4 additions & 4 deletions src/Console/Commands/RegisterReacters.php
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
namespace Cog\Laravel\Love\Console\Commands;

use Cog\Contracts\Love\Reacterable\Exceptions\ReacterableInvalid;
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableContract;
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableInterface;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\Relation;
@@ -94,14 +94,14 @@ public function handle(): int
*/
private function reacterableModelFromType(
string $modelType
): ReacterableContract {
): ReacterableInterface {
if (!class_exists($modelType)) {
$modelType = $this->findModelTypeInMorphMap($modelType);
}

$model = new $modelType();

if (!$model instanceof ReacterableContract) {
if (!$model instanceof ReacterableInterface) {
throw ReacterableInvalid::notImplementInterface($modelType);
}

@@ -149,7 +149,7 @@ private function normalizeIds(array $modelIds): array
* @return Collection
*/
private function collectModels(
ReacterableContract $reacterableModel,
ReacterableInterface $reacterableModel,
array $modelIds
): Collection {
$query = $reacterableModel
4 changes: 2 additions & 2 deletions src/Console/Commands/SetupReactable.php
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@

namespace Cog\Laravel\Love\Console\Commands;

use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableContract;
use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableInterface;
use Cog\Laravel\Love\Reactant\Models\Reactant;
use Cog\Laravel\Love\Support\Database\AddForeignColumnStub;
use Cog\Laravel\Love\Support\Database\MigrationCreator;
@@ -170,7 +170,7 @@ private function sanitizeName(string $name): string

private function isModelInvalid(Model $model): bool
{
return !$model instanceof ReactableContract;
return !$model instanceof ReactableInterface;
}

private function getMigrationsPath(): string
4 changes: 2 additions & 2 deletions src/Console/Commands/SetupReacterable.php
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@

namespace Cog\Laravel\Love\Console\Commands;

use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableContract;
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableInterface;
use Cog\Laravel\Love\Reacter\Models\Reacter;
use Cog\Laravel\Love\Support\Database\AddForeignColumnStub;
use Cog\Laravel\Love\Support\Database\MigrationCreator;
@@ -170,7 +170,7 @@ private function sanitizeName(string $name): string

private function isModelInvalid(Model $model): bool
{
return !$model instanceof ReacterableContract;
return !$model instanceof ReacterableInterface;
}

private function getMigrationsPath(): string
12 changes: 6 additions & 6 deletions src/Console/Commands/UpgradeV5ToV6.php
Original file line number Diff line number Diff line change
@@ -13,8 +13,8 @@

namespace Cog\Laravel\Love\Console\Commands;

use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableContract;
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableContract;
use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableInterface;
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableInterface;
use Cog\Laravel\Love\Reaction\Models\Reaction;
use Cog\Laravel\Love\ReactionType\Models\ReactionType;
use Illuminate\Console\Command;
@@ -145,7 +145,7 @@ private function populateReacters(): void
continue;
}

if (!in_array(ReacterableContract::class, class_implements($class))) {
if (!in_array(ReacterableInterface::class, class_implements($class))) {
$this->warn("Class `{$class}` need to implement Reacterable contract.");
continue;
}
@@ -192,7 +192,7 @@ private function populateReactants(): void
continue;
}

if (!in_array(ReactableContract::class, class_implements($class))) {
if (!in_array(ReactableInterface::class, class_implements($class))) {
$this->warn("Class `{$class}` need to implement Reactable contract.");
continue;
}
@@ -246,7 +246,7 @@ private function populateReactions(): void
continue;
}

/** @var ReactableContract $reactable */
/** @var ReactableInterface $reactable */
$reactable = $class::whereKey($like->likeable_id)->firstOrFail();

$userClass = $this->getUserClass();
@@ -257,7 +257,7 @@ private function populateReactions(): void
continue;
}

/** @var ReacterableContract $reacterable */
/** @var ReacterableInterface $reacterable */
$reacterable = $userClass::whereKey($like->user_id)->firstOrFail();
$reactionTypeName = $this->reactionTypeNameFromLikeTypeName($like->type_id);

14 changes: 7 additions & 7 deletions src/Reactable/Models/Traits/Reactable.php
Original file line number Diff line number Diff line change
@@ -14,9 +14,9 @@
namespace Cog\Laravel\Love\Reactable\Models\Traits;

use Cog\Contracts\Love\Reactable\Exceptions\AlreadyRegisteredAsLoveReactant;
use Cog\Contracts\Love\Reactant\Facades\Reactant as ReactantFacadeContract;
use Cog\Contracts\Love\Reactant\Models\Reactant as ReactantContract;
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableContract;
use Cog\Contracts\Love\Reactant\Facades\Reactant as ReactantFacadeInterface;
use Cog\Contracts\Love\Reactant\Models\Reactant as ReactantInterface;
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableInterface;
use Cog\Laravel\Love\Reactable\Observers\ReactableObserver;
use Cog\Laravel\Love\Reactant\Facades\Reactant as ReactantFacade;
use Cog\Laravel\Love\Reactant\Models\NullReactant;
@@ -45,12 +45,12 @@ public function loveReactant(): BelongsTo
return $this->belongsTo(Reactant::class, 'love_reactant_id');
}

public function getLoveReactant(): ReactantContract
public function getLoveReactant(): ReactantInterface
{
return $this->getAttribute('loveReactant') ?? new NullReactant($this);
}

public function viaLoveReactant(): ReactantFacadeContract
public function viaLoveReactant(): ReactantFacadeInterface
{
return new ReactantFacade($this->getLoveReactant());
}
@@ -82,7 +82,7 @@ public function registerAsLoveReactant(): void

public function scopeWhereReactedBy(
Builder $query,
ReacterableContract $reacterable,
ReacterableInterface $reacterable,
?string $reactionTypeName = null
): Builder {
return $query->whereHas('loveReactant.reactions', function (Builder $reactionsQuery) use ($reacterable, $reactionTypeName) {
@@ -95,7 +95,7 @@ public function scopeWhereReactedBy(

public function scopeWhereNotReactedBy(
Builder $query,
ReacterableContract $reacterable,
ReacterableInterface $reacterable,
?string $reactionTypeName = null
): Builder {
return $query->whereDoesntHave('loveReactant.reactions', function (Builder $reactionsQuery) use ($reacterable, $reactionTypeName) {
6 changes: 3 additions & 3 deletions src/Reactable/Observers/ReactableObserver.php
Original file line number Diff line number Diff line change
@@ -13,12 +13,12 @@

namespace Cog\Laravel\Love\Reactable\Observers;

use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableContract;
use Cog\Contracts\Love\Reactable\Models\Reactable as ReactableInterface;

final class ReactableObserver
{
public function created(
ReactableContract $reactable
ReactableInterface $reactable
): void {
if ($this->shouldRegisterAsReactantOnCreate($reactable)
&& $reactable->isNotRegisteredAsLoveReactant()) {
@@ -27,7 +27,7 @@ public function created(
}

private function shouldRegisterAsReactantOnCreate(
ReactableContract $reactable
ReactableInterface $reactable
): bool {
return !method_exists($reactable, 'shouldRegisterAsLoveReactantOnCreate')
|| $reactable->shouldRegisterAsLoveReactantOnCreate();
24 changes: 12 additions & 12 deletions src/Reactant/Facades/Reactant.php
Original file line number Diff line number Diff line change
@@ -13,22 +13,22 @@

namespace Cog\Laravel\Love\Reactant\Facades;

use Cog\Contracts\Love\Reactant\Facades\Reactant as ReacterFacadeContract;
use Cog\Contracts\Love\Reactant\Models\Reactant as ReactantContract;
use Cog\Contracts\Love\Reactant\ReactionCounter\Models\ReactionCounter as ReactionCounterContract;
use Cog\Contracts\Love\Reactant\ReactionTotal\Models\ReactionTotal as ReactionTotalContract;
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableContract;
use Cog\Contracts\Love\Reactant\Facades\Reactant as ReacterFacadeInterface;
use Cog\Contracts\Love\Reactant\Models\Reactant as ReactantInterface;
use Cog\Contracts\Love\Reactant\ReactionCounter\Models\ReactionCounter as ReactionCounterInterface;
use Cog\Contracts\Love\Reactant\ReactionTotal\Models\ReactionTotal as ReactionTotalInterface;
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableInterface;
use Cog\Laravel\Love\ReactionType\Models\ReactionType;

final class Reactant implements
ReacterFacadeContract
ReacterFacadeInterface
{
/**
* @var ReactantContract
* @var ReactantInterface
*/
private $reactant;

public function __construct(ReactantContract $reactant)
public function __construct(ReactantInterface $reactant)
{
$this->reactant = $reactant;
}
@@ -51,19 +51,19 @@ public function getReactionCounters(): iterable

public function getReactionCounterOfType(
string $reactionTypeName
): ReactionCounterContract {
): ReactionCounterInterface {
return $this->reactant->getReactionCounterOfType(
ReactionType::fromName($reactionTypeName)
);
}

public function getReactionTotal(): ReactionTotalContract
public function getReactionTotal(): ReactionTotalInterface
{
return $this->reactant->getReactionTotal();
}

public function isReactedBy(
?ReacterableContract $reacterable = null,
?ReacterableInterface $reacterable = null,
?string $reactionTypeName = null,
?float $rate = null
): bool {
@@ -81,7 +81,7 @@ public function isReactedBy(
}

public function isNotReactedBy(
?ReacterableContract $reacterable = null,
?ReacterableInterface $reacterable = null,
?string $reactionTypeName = null,
?float $rate = null
): bool {
Loading

0 comments on commit 526d12d

Please sign in to comment.