Skip to content

Commit

Permalink
Renamed DateTimePeriod to DateRange
Browse files Browse the repository at this point in the history
  • Loading branch information
florianv committed Aug 27, 2015
1 parent bc501d3 commit fca0c6b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use Business\Day;
use Business\Days;
use Business\Business;
use Business\Holidays;
use Business\DateTimePeriod;
use Business\DateRange;

// Opening hours for each week day. If not specified, it is considered closed
$days = [
Expand All @@ -42,7 +42,7 @@ $days = [
$holidays = new Holidays([
new \DateTime('2015-01-01'),
new \DateTime('2015-01-02'),
new DateTimePeriod(new \DateTime('2015-07-08'), new \DateTime('2015-07-11')),
new DateRange(new \DateTime('2015-07-08'), new \DateTime('2015-07-11')),
]);

// Optional business timezone
Expand Down
4 changes: 2 additions & 2 deletions src/DateTimePeriod.php → src/DateRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
namespace Business;

/**
* DateTime period implementation.
* Date range.
*
* @author Márk Sági-Kazár <[email protected]>
*/
final class DateTimePeriod implements \IteratorAggregate
final class DateRange implements \IteratorAggregate
{
private $datePeriod;

Expand Down
6 changes: 3 additions & 3 deletions src/Holidays.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class Holidays implements \Serializable
/**
* Creates a new holiday collection.
*
* @param \DateTime[]|DateTimePeriod[] $holidays
* @param \DateTime[]|DateRange[] $holidays
*/
public function __construct(array $holidays = [])
{
Expand Down Expand Up @@ -75,12 +75,12 @@ private function addHoliday(\DateTime $holiday)
/**
* Adds a set of days.
*
* @param \DateTime[]|DateTimePeriod[]|DateTimePeriod $holidays
* @param \DateTime[]|DateRange[]|DateRange $holidays
*/
private function addHolidays($holidays)
{
foreach ($holidays as $holiday) {
if ($holiday instanceof DateTimePeriod) {
if ($holiday instanceof DateRange) {
$this->addHolidays($holiday);

continue;
Expand Down
12 changes: 6 additions & 6 deletions tests/DateTimePeriodTest.php → tests/DateRangeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

namespace Business\Tests;

use Business\DateTimePeriod;
use Business\DateRange;

class DateTimePeriodTest extends \PHPUnit_Framework_TestCase
class DateRangeTest extends \PHPUnit_Framework_TestCase
{
public function testIterator()
{
$dateTimePeriod = new DateTimePeriod(new \DateTime('2015-07-08'), new \DateTime('2015-07-13'));
$dateRange = new DateRange(new \DateTime('2015-07-08'), new \DateTime('2015-07-13'));

$this->assertInstanceOf('DatePeriod', $dateTimePeriod->getIterator());
$this->assertInstanceOf('DatePeriod', $dateRange->getIterator());

$expected = [
'2015-07-08',
Expand All @@ -31,7 +31,7 @@ public function testIterator()
];
$actual = [];

foreach ($dateTimePeriod as $dateTime) {
foreach ($dateRange as $dateTime) {
$actual[] = $dateTime->format('Y-m-d');
}

Expand All @@ -44,6 +44,6 @@ public function testIterator()
*/
public function testStartDateIsEarlier()
{
$dateTimePeriod = new DateTimePeriod(new \DateTime('2015-07-08'), new \DateTime('2015-07-07'));
new DateRange(new \DateTime('2015-07-08'), new \DateTime('2015-07-07'));
}
}
6 changes: 3 additions & 3 deletions tests/HolidaysTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Business\Tests;

use Business\DateTimePeriod;
use Business\DateRange;
use Business\Holidays;

class HolidaysTest extends \PHPUnit_Framework_TestCase
Expand All @@ -20,7 +20,7 @@ public function testIsHoliday()
{
$holidays = new Holidays([
$holiday = new \DateTime('2015-05-11'),
new DateTimePeriod(new \DateTime('2015-07-08'), new \DateTime('2015-07-21'))
new DateRange(new \DateTime('2015-07-08'), new \DateTime('2015-07-21'))
]);

$this->assertTrue($holidays->isHoliday($holiday));
Expand All @@ -31,7 +31,7 @@ public function testSerializeUnserialize()
{
$holidays = new Holidays([
$holiday = new \DateTime('2015-05-11'),
new DateTimePeriod(new \DateTime('2015-07-08'), new \DateTime('2015-07-21'))
new DateRange(new \DateTime('2015-07-08'), new \DateTime('2015-07-21'))
]);

$serialized = serialize($holidays);
Expand Down

0 comments on commit fca0c6b

Please sign in to comment.