Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
108 additions
and
53 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
namespace Spil; | ||
|
||
final class Key | ||
{ | ||
private $teeth; | ||
|
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 |
---|---|---|
@@ -1,24 +1,28 @@ | ||
<?php | ||
|
||
namespace Spil; | ||
|
||
use DateTime; | ||
|
||
final class LockFactory | ||
{ | ||
public function createUnlockedLock($secret) | ||
{ | ||
return new Lock($secret, new UnlockedState()); | ||
return new Lock($secret, new LockState\UnlockedState()); | ||
} | ||
|
||
public function createLockedLock($secret) | ||
{ | ||
return new Lock($secret, new LockedState()); | ||
return new Lock($secret, new LockState\LockedState()); | ||
} | ||
|
||
public function createTemporalUnlockedLock($secret, DateTime $from, DateTime $until) | ||
{ | ||
return new Lock($secret, new TemporalUnlockedState(new TimeFrame($from, $until))); | ||
return new Lock($secret, new LockState\TemporalUnlockedState(new TimeFrame($from, $until))); | ||
} | ||
|
||
public function createTemporalLockedLock($secret, DateTime $from, DateTime $until) | ||
{ | ||
return new Lock($secret, new TemporalLockedState(new TimeFrame($from, $until))); | ||
return new Lock($secret, new LockState\TemporalLockedState(new TimeFrame($from, $until))); | ||
} | ||
} |
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,9 @@ | ||
<?php | ||
|
||
namespace Spil\LockState; | ||
|
||
final interface LockStateInterface | ||
{ | ||
function lock(); | ||
function unlock(); | ||
} |
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,16 @@ | ||
<?php | ||
|
||
namespace Spil\LockState; | ||
|
||
final class LockedState implements LockStateInterface | ||
{ | ||
public function lock() | ||
{ | ||
throw new \DomainException("Already locked"); | ||
} | ||
|
||
public function unlock() | ||
{ | ||
return new UnlockedState; | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
namespace Spil\LockState; | ||
|
||
final class UnLockedState implements LockStateInterface | ||
{ | ||
public function lock() | ||
{ | ||
return new LockedState; | ||
} | ||
|
||
public function unlock() | ||
{ | ||
throw new \DomainException("Already unlocked"); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
<?php | ||
|
||
namespace Spil; | ||
|
||
use DateTime; | ||
|
||
final class TimeFrame | ||
{ | ||
private $from; | ||
|
This file was deleted.
Oops, something went wrong.