-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed RedisCounter and added a native counter
- Loading branch information
Showing
11 changed files
with
125 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace ekinhbayar\GitAmp\Storage; | ||
|
||
class NativeCounter implements Counter | ||
{ | ||
private $counter = 0; | ||
|
||
public function increment() | ||
{ | ||
$this->counter++; | ||
} | ||
|
||
public function decrement() | ||
{ | ||
$this->counter--; | ||
} | ||
|
||
public function get(): int | ||
{ | ||
return $this->counter; | ||
} | ||
|
||
public function set(int $val) | ||
{ | ||
$this->counter = $val; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace ekinhbayar\GitAmpTests\Storage; | ||
|
||
use ekinhbayar\GitAmp\Storage\NativeCounter; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class NativeCounterTest extends TestCase | ||
{ | ||
public function testGet() | ||
{ | ||
$nativeCounter = new NativeCounter(); | ||
|
||
$this->assertSame(0, $nativeCounter->get()); | ||
} | ||
|
||
public function testSet() | ||
{ | ||
$nativeCounter = new NativeCounter(); | ||
|
||
$nativeCounter->set(5); | ||
|
||
$this->assertSame(5, $nativeCounter->get()); | ||
} | ||
|
||
public function testIncrement() | ||
{ | ||
$nativeCounter = new NativeCounter(); | ||
|
||
$nativeCounter->increment(); | ||
|
||
$this->assertSame(1, $nativeCounter->get()); | ||
|
||
$nativeCounter->increment(); | ||
|
||
$this->assertSame(2, $nativeCounter->get()); | ||
|
||
$nativeCounter->increment(); | ||
|
||
$this->assertSame(3, $nativeCounter->get()); | ||
} | ||
|
||
public function testDecrement() | ||
{ | ||
$nativeCounter = new NativeCounter(); | ||
|
||
$nativeCounter->set(5); | ||
|
||
$nativeCounter->decrement(); | ||
|
||
$this->assertSame(4, $nativeCounter->get()); | ||
|
||
$nativeCounter->decrement(); | ||
|
||
$this->assertSame(3, $nativeCounter->get()); | ||
|
||
$nativeCounter->decrement(); | ||
|
||
$this->assertSame(2, $nativeCounter->get()); | ||
} | ||
} |
Oops, something went wrong.