Skip to content

Fix violation of the Interface Segregation Principle #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/Reactant/Models/Reactant.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
use I\Love\Reactant\ReactionTotal\Models\ReactionTotal;
use I\Love\Reacter\Models\Reacter;
use I\Love\ReactionType\Models\ReactionType;
use I\Love\Support\Object\Nullable;

interface Reactant
interface Reactant extends
Nullable
{
public function getId(): string;

Expand Down Expand Up @@ -47,10 +49,6 @@ public function isEqualTo(self $that): bool;

public function isNotEqualTo(self $that): bool;

public function isNull(): bool;

public function isNotNull(): bool;

public function createReactionCounterOfType(ReactionType $type): void;

public function createReactionTotal(): void;
Expand Down
18 changes: 5 additions & 13 deletions src/Reactant/ReactionCounter/Models/ReactionCounter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@

use I\Love\Reactant\Models\Reactant;
use I\Love\ReactionType\Models\ReactionType;
use I\Love\Support\Object\Countable;
use I\Love\Support\Object\Weightable;

interface ReactionCounter
interface ReactionCounter extends
Countable,
Weightable
{
public function getReactant(): Reactant;

Expand All @@ -25,16 +29,4 @@ public function getReactionType(): ReactionType;
public function isReactionOfType(ReactionType $type): bool;

public function isNotReactionOfType(ReactionType $type): bool;

public function getCount(): int;

public function getWeight(): float;

public function incrementCount(int $amount): void;

public function decrementCount(int $amount): void;

public function incrementWeight(float $amount): void;

public function decrementWeight(float $amount): void;
}
18 changes: 5 additions & 13 deletions src/Reactant/ReactionTotal/Models/ReactionTotal.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,12 @@
namespace I\Love\Reactant\ReactionTotal\Models;

use I\Love\Reactant\Models\Reactant;
use I\Love\Support\Object\Countable;
use I\Love\Support\Object\Weightable;

interface ReactionTotal
interface ReactionTotal extends
Countable,
Weightable
{
public function getReactant(): Reactant;

public function getCount(): int;

public function getWeight(): float;

public function incrementCount(int $amount): void;

public function decrementCount(int $amount): void;

public function incrementWeight(float $amount): void;

public function decrementWeight(float $amount): void;
}
8 changes: 3 additions & 5 deletions src/Reacter/Models/Reacter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
use I\Love\Reactant\Models\Reactant;
use I\Love\Reacterable\Models\Reacterable;
use I\Love\ReactionType\Models\ReactionType;
use I\Love\Support\Object\Nullable;

interface Reacter
interface Reacter extends
Nullable
{
public function getId(): string;

Expand All @@ -39,8 +41,4 @@ public function hasNotReactedTo(Reactant $reactant, ?ReactionType $reactionType
public function isEqualTo(self $that): bool;

public function isNotEqualTo(self $that): bool;

public function isNull(): bool;

public function isNotNull(): bool;
}
23 changes: 23 additions & 0 deletions src/Support/Object/Countable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/*
* This file is part of PHP I: Love.
*
* (c) Anton Komarev <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace I\Love\Support\Object;

interface Countable
{
public function getCount(): int;

public function incrementCount(int $amount): void;

public function decrementCount(int $amount): void;
}
21 changes: 21 additions & 0 deletions src/Support/Object/Nullable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/*
* This file is part of PHP I: Love.
*
* (c) Anton Komarev <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace I\Love\Support\Object;

interface Nullable
{
public function isNull(): bool;

public function isNotNull(): bool;
}
23 changes: 23 additions & 0 deletions src/Support/Object/Weightable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/*
* This file is part of PHP I: Love.
*
* (c) Anton Komarev <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace I\Love\Support\Object;

interface Weightable
{
public function getWeight(): float;

public function incrementWeight(float $amount): void;

public function decrementWeight(float $amount): void;
}