Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Closed #15 Renamed Event to UnitOfTime

  • Loading branch information...
commit dfddfeaf27f966aad026d07ee9c37cc25093211c 1 parent a317af4
@jeremyFreeAgent authored
View
22 src/FreeAgent/Bitter/Bitter.php
@@ -5,12 +5,12 @@
use \DateTime;
use \Exception;
use FreeAgent\Bitter\Date\DatePeriod;
-use FreeAgent\Bitter\Event\Year;
-use FreeAgent\Bitter\Event\Month;
-use FreeAgent\Bitter\Event\Week;
-use FreeAgent\Bitter\Event\Day;
-use FreeAgent\Bitter\Event\Hour;
-use FreeAgent\Bitter\Event\EventInterface;
+use FreeAgent\Bitter\UnitOfTime\Year;
+use FreeAgent\Bitter\UnitOfTime\Month;
+use FreeAgent\Bitter\UnitOfTime\Week;
+use FreeAgent\Bitter\UnitOfTime\Day;
+use FreeAgent\Bitter\UnitOfTime\Hour;
+use FreeAgent\Bitter\UnitOfTime\UnitOfTimeInterface;
/**
* @author Jérémy Romey <jeremy@free-agent.fr>
@@ -89,7 +89,7 @@ public function mark($eventName, $id, DateTime $dateTime = null)
*/
public function in($id, $key)
{
- $key = $key instanceof EventInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;
+ $key = $key instanceof UnitOfTimeInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;
return (bool) $this->getRedisClient()->getbit($key, $id);
}
@@ -102,15 +102,15 @@ public function in($id, $key)
*/
public function count($key)
{
- $key = $key instanceof EventInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;
+ $key = $key instanceof UnitOfTimeInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;
return (int) $this->getRedisClient()->bitcount($key);
}
private function bitOp($op, $destKey, $keyOne, $keyTwo)
{
- $keyOne = $keyOne instanceof EventInterface ? $this->prefixKey . $keyOne->getKey() : $this->prefixTempKey . $keyOne;
- $keyTwo = $keyTwo instanceof EventInterface ? $this->prefixKey . $keyTwo->getKey() : $this->prefixTempKey . $keyTwo;
+ $keyOne = $keyOne instanceof UnitOfTimeInterface ? $this->prefixKey . $keyOne->getKey() : $this->prefixTempKey . $keyOne;
+ $keyTwo = $keyTwo instanceof UnitOfTimeInterface ? $this->prefixKey . $keyTwo->getKey() : $this->prefixTempKey . $keyTwo;
$this->getRedisClient()->bitop($op, $this->prefixTempKey . $destKey, $keyOne, $keyTwo);
$this->getRedisClient()->sadd($this->prefixTempKey . 'keys', $destKey);
@@ -198,7 +198,7 @@ public function bitDateRange($key, $destKey, DateTime $from, DateTime $to)
*/
public function getIds($key)
{
- $key = $key instanceof EventInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;
+ $key = $key instanceof UnitOfTimeInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;
$string = $this->getRedisClient()->get($key);
View
8 src/FreeAgent/Bitter/Event/AbstractEvent.php → .../Bitter/UnitOfTime/AbstractUnitOfTime.php
@@ -1,6 +1,6 @@
<?php
-namespace FreeAgent\Bitter\Event;
+namespace FreeAgent\Bitter\UnitOfTime;
use \DateTime;
use \Exception;
@@ -8,7 +8,7 @@
/**
* @author Jérémy Romey <jeremy@free-agent.fr>
*/
-abstract class AbstractEvent
+abstract class AbstractUnitOfTime
{
protected $eventName;
protected $dateTime;
@@ -19,7 +19,7 @@ public function __construct($eventName, DateTime $dateTime = null)
$this->dateTime = is_null($dateTime) ? new DateTime : $dateTime;
}
- public function getEventName()
+ public function getUnitOfTimeName()
{
return $this->eventName;
}
@@ -33,6 +33,6 @@ public function getDateTime()
public function getKey()
{
- return sprintf('%s:%s', $this->getEventName(), $this->getDateTimeFormated());
+ return sprintf('%s:%s', $this->getUnitOfTimeName(), $this->getDateTimeFormated());
}
}
View
4 src/FreeAgent/Bitter/Event/Day.php → src/FreeAgent/Bitter/UnitOfTime/Day.php
@@ -1,11 +1,11 @@
<?php
-namespace FreeAgent\Bitter\Event;
+namespace FreeAgent\Bitter\UnitOfTime;
/**
* @author Jérémy Romey <jeremy@free-agent.fr>
*/
-class Day extends AbstractEvent implements EventInterface
+class Day extends AbstractUnitOfTime implements UnitOfTimeInterface
{
public function getDateTimeFormated()
{
View
4 src/FreeAgent/Bitter/Event/Hour.php → src/FreeAgent/Bitter/UnitOfTime/Hour.php
@@ -1,11 +1,11 @@
<?php
-namespace FreeAgent\Bitter\Event;
+namespace FreeAgent\Bitter\UnitOfTime;
/**
* @author Jérémy Romey <jeremy@free-agent.fr>
*/
-class Hour extends AbstractEvent implements EventInterface
+class Hour extends AbstractUnitOfTime implements UnitOfTimeInterface
{
public function getDateTimeFormated()
{
View
4 src/FreeAgent/Bitter/Event/Month.php → src/FreeAgent/Bitter/UnitOfTime/Month.php
@@ -1,11 +1,11 @@
<?php
-namespace FreeAgent\Bitter\Event;
+namespace FreeAgent\Bitter\UnitOfTime;
/**
* @author Jérémy Romey <jeremy@free-agent.fr>
*/
-class Month extends AbstractEvent implements EventInterface
+class Month extends AbstractUnitOfTime implements UnitOfTimeInterface
{
public function getDateTimeFormated()
{
View
6 ...FreeAgent/Bitter/Event/EventInterface.php → ...Bitter/UnitOfTime/UnitOfTimeInterface.php
@@ -1,14 +1,14 @@
<?php
-namespace FreeAgent\Bitter\Event;
+namespace FreeAgent\Bitter\UnitOfTime;
/**
* @author Jérémy Romey <jeremy@free-agent.fr>
*/
-interface EventInterface
+interface UnitOfTimeInterface
{
public function __construct($eventName, \DateTime $dateTime);
- public function getEventName();
+ public function getUnitOfTimeName();
public function getDateTime();
public function getDateTimeFormated();
public function getKey();
View
4 src/FreeAgent/Bitter/Event/Week.php → src/FreeAgent/Bitter/UnitOfTime/Week.php
@@ -1,11 +1,11 @@
<?php
-namespace FreeAgent\Bitter\Event;
+namespace FreeAgent\Bitter\UnitOfTime;
/**
* @author Jérémy Romey <jeremy@free-agent.fr>
*/
-class Week extends AbstractEvent implements EventInterface
+class Week extends AbstractUnitOfTime implements UnitOfTimeInterface
{
public function getDateTimeFormated()
{
View
4 src/FreeAgent/Bitter/Event/Year.php → src/FreeAgent/Bitter/UnitOfTime/Year.php
@@ -1,11 +1,11 @@
<?php
-namespace FreeAgent\Bitter\Event;
+namespace FreeAgent\Bitter\UnitOfTime;
/**
* @author Jérémy Romey <jeremy@free-agent.fr>
*/
-class Year extends AbstractEvent implements EventInterface
+class Year extends AbstractUnitOfTime implements UnitOfTimeInterface
{
public function getDateTimeFormated()
{
View
4 tests/units/Bitter.php
@@ -7,7 +7,7 @@
use \mageekguy\atoum;
use \DateTime;
use FreeAgent\Bitter\Bitter as TestedBitter;
-use FreeAgent\Bitter\Event\Day;
+use FreeAgent\Bitter\UnitOfTime\Day;
/**
* @engine isolate
@@ -72,7 +72,7 @@ public function testConstruct($redisClient)
/**
* @dataProvider dataProviderTestedClients
*/
- public function testMarkEvent($redisClient)
+ public function testMarkUnitOfTime($redisClient)
{
$bitter = new TestedBitter($redisClient, $this->getPrefixKey(), $this->getPrefixTempKey());
View
12 tests/units/Event/AbstractEvent.php → ...s/units/UnitOfTime/AbstractUnitOfTime.php
@@ -1,30 +1,30 @@
<?php
-namespace FreeAgent\Bitter\tests\units\Event;
+namespace FreeAgent\Bitter\tests\units\UnitOfTime;
require_once __DIR__ . '/../../../vendor/autoload.php';
use \mageekguy\atoum;
use \DateTime;
-use FreeAgent\Bitter\Event\AbstractEvent as TestedAbstractEvent;
+use FreeAgent\Bitter\UnitOfTime\AbstractUnitOfTime as TestedAbstractUnitOfTime;
/**
* @author Jérémy Romey <jeremy@free-agent.fr>
*/
-class AbstractEvent extends atoum\test
+class AbstractUnitOfTime extends atoum\test
{
public function testConstruct()
{
$dateTime = DateTime::createFromFormat('Y-m-d H:i:s', '2012-11-06 15:30:45');
- $event = new \mock\FreeAgent\Bitter\Event\AbstractEvent('drink_a_bitter_beer', $dateTime);
+ $event = new \mock\FreeAgent\Bitter\UnitOfTime\AbstractUnitOfTime('drink_a_bitter_beer', $dateTime);
$this
->variable($event->getDateTime())
->isIdenticalTo($dateTime)
;
$this
- ->variable($event->getEventName())
+ ->variable($event->getUnitOfTimeName())
->isIdenticalTo('drink_a_bitter_beer')
;
}
@@ -33,7 +33,7 @@ public function testGetKey()
{
$dateTime = DateTime::createFromFormat('Y-m-d H:i:s', '2012-11-06 15:30:45');
- $event = new \mock\FreeAgent\Bitter\Event\AbstractEvent('drink_a_bitter_beer', $dateTime);
+ $event = new \mock\FreeAgent\Bitter\UnitOfTime\AbstractUnitOfTime('drink_a_bitter_beer', $dateTime);
$event->getMockController()->getDateTimeFormated = '2012-11-06';
View
8 tests/units/Event/Day.php → tests/units/UnitOfTime/Day.php
@@ -1,12 +1,12 @@
<?php
-namespace FreeAgent\Bitter\tests\units\Event;
+namespace FreeAgent\Bitter\tests\units\UnitOfTime;
require_once __DIR__ . '/../../../vendor/autoload.php';
use \mageekguy\atoum;
use \DateTime;
-use FreeAgent\Bitter\Event\Day as TestedDay;
+use FreeAgent\Bitter\UnitOfTime\Day as TestedDay;
/**
* @author Jérémy Romey <jeremy@free-agent.fr>
@@ -19,8 +19,8 @@ public function testConstruct()
$this
->object($day)
- ->isInstanceOf('FreeAgent\Bitter\Event\AbstractEvent')
- ->isInstanceOf('FreeAgent\Bitter\Event\EventInterface')
+ ->isInstanceOf('FreeAgent\Bitter\UnitOfTime\AbstractUnitOfTime')
+ ->isInstanceOf('FreeAgent\Bitter\UnitOfTime\UnitOfTimeInterface')
;
}
View
8 tests/units/Event/Hour.php → tests/units/UnitOfTime/Hour.php
@@ -1,12 +1,12 @@
<?php
-namespace FreeAgent\Bitter\tests\units\Event;
+namespace FreeAgent\Bitter\tests\units\UnitOfTime;
require_once __DIR__ . '/../../../vendor/autoload.php';
use \mageekguy\atoum;
use \DateTime;
-use FreeAgent\Bitter\Event\Hour as TestedHour;
+use FreeAgent\Bitter\UnitOfTime\Hour as TestedHour;
/**
* @author Jérémy Romey <jeremy@free-agent.fr>
@@ -19,8 +19,8 @@ public function testConstruct()
$this
->object($hour)
- ->isInstanceOf('FreeAgent\Bitter\Event\AbstractEvent')
- ->isInstanceOf('FreeAgent\Bitter\Event\EventInterface')
+ ->isInstanceOf('FreeAgent\Bitter\UnitOfTime\AbstractUnitOfTime')
+ ->isInstanceOf('FreeAgent\Bitter\UnitOfTime\UnitOfTimeInterface')
;
}
View
8 tests/units/Event/Month.php → tests/units/UnitOfTime/Month.php
@@ -1,12 +1,12 @@
<?php
-namespace FreeAgent\Bitter\tests\units\Event;
+namespace FreeAgent\Bitter\tests\units\UnitOfTime;
require_once __DIR__ . '/../../../vendor/autoload.php';
use \mageekguy\atoum;
use \DateTime;
-use FreeAgent\Bitter\Event\Month as TestedMonth;
+use FreeAgent\Bitter\UnitOfTime\Month as TestedMonth;
/**
* @author Jérémy Romey <jeremy@free-agent.fr>
@@ -19,8 +19,8 @@ public function testConstruct()
$this
->object($month)
- ->isInstanceOf('FreeAgent\Bitter\Event\AbstractEvent')
- ->isInstanceOf('FreeAgent\Bitter\Event\EventInterface')
+ ->isInstanceOf('FreeAgent\Bitter\UnitOfTime\AbstractUnitOfTime')
+ ->isInstanceOf('FreeAgent\Bitter\UnitOfTime\UnitOfTimeInterface')
;
}
View
8 tests/units/Event/Week.php → tests/units/UnitOfTime/Week.php
@@ -1,12 +1,12 @@
<?php
-namespace FreeAgent\Bitter\tests\units\Event;
+namespace FreeAgent\Bitter\tests\units\UnitOfTime;
require_once __DIR__ . '/../../../vendor/autoload.php';
use \mageekguy\atoum;
use \DateTime;
-use FreeAgent\Bitter\Event\Week as TestedWeek;
+use FreeAgent\Bitter\UnitOfTime\Week as TestedWeek;
/**
* @author Jérémy Romey <jeremy@free-agent.fr>
@@ -19,8 +19,8 @@ public function testConstruct()
$this
->object($week)
- ->isInstanceOf('FreeAgent\Bitter\Event\AbstractEvent')
- ->isInstanceOf('FreeAgent\Bitter\Event\EventInterface')
+ ->isInstanceOf('FreeAgent\Bitter\UnitOfTime\AbstractUnitOfTime')
+ ->isInstanceOf('FreeAgent\Bitter\UnitOfTime\UnitOfTimeInterface')
;
}
View
8 tests/units/Event/Year.php → tests/units/UnitOfTime/Year.php
@@ -1,12 +1,12 @@
<?php
-namespace FreeAgent\Bitter\tests\units\Event;
+namespace FreeAgent\Bitter\tests\units\UnitOfTime;
require_once __DIR__ . '/../../../vendor/autoload.php';
use \mageekguy\atoum;
use \DateTime;
-use FreeAgent\Bitter\Event\Year as TestedYear;
+use FreeAgent\Bitter\UnitOfTime\Year as TestedYear;
/**
* @author Jérémy Romey <jeremy@free-agent.fr>
@@ -19,8 +19,8 @@ public function testConstruct()
$this
->object($month)
- ->isInstanceOf('FreeAgent\Bitter\Event\AbstractEvent')
- ->isInstanceOf('FreeAgent\Bitter\Event\EventInterface')
+ ->isInstanceOf('FreeAgent\Bitter\UnitOfTime\AbstractUnitOfTime')
+ ->isInstanceOf('FreeAgent\Bitter\UnitOfTime\UnitOfTimeInterface')
;
}
Please sign in to comment.
Something went wrong with that request. Please try again.