Skip to content

Commit

Permalink
Merge pull request #12 from texthtml/feature/factory-interface
Browse files Browse the repository at this point in the history
add \TH\Lock\Factory interface
  • Loading branch information
mathroc committed Nov 19, 2015
2 parents 84539e1 + 0b74944 commit b5e5c97
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions spec/TH/Lock/FileFactorySpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function let()
public function it_is_initializable()
{
$this->shouldHaveType('TH\Lock\FileFactory');
$this->shouldImplement('TH\Lock\Factory');
}

public function it_should_create_a_file_lock()
Expand Down
14 changes: 14 additions & 0 deletions src/Factory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace TH\Lock;

interface Factory
{
/**
* Create a Lock for $resource
*
* @param string $resource resource identifier
* @return Lock
*/
public function create($resource);
}
2 changes: 1 addition & 1 deletion src/FileFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;

class FileFactory
class FileFactory implements Factory
{
private $lock_dir;
private $hash_algo;
Expand Down
15 changes: 15 additions & 0 deletions src/TtlFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace TH\Lock;

interface TtlFactory extends Factory
{
/**
* Create a Lock for $resource
*
* @param string $resource resource identifier
* @param integer $ttl lock time-to-live in milliseconds
* @return Lock
*/
public function create($resource, $ttl = null);
}

0 comments on commit b5e5c97

Please sign in to comment.