Skip to content
This repository was archived by the owner on Oct 26, 2024. It is now read-only.

Commit 004faba

Browse files
committed
Documentation improvements, more test coverage for Timer
1 parent 13c6ac5 commit 004faba

File tree

4 files changed

+34
-34
lines changed

4 files changed

+34
-34
lines changed

Config/Config.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,13 @@ public static function factory(array $param, $class = 'ConfigDefault')
4545

4646
// allow config names without ending
4747
if (empty($param['file'])) {
48-
throw new \InvalidArgumentException(
49-
'Config::factory() - config filename missing in param array!'
50-
);
48+
throw new \InvalidArgumentException('Config::factory() - config filename missing in param array!');
5149
}
5250

5351
return new $class($param);
5452
} else {
5553
throw new \ErrorException(
56-
'Config::factory() - could not instantiate ' .
57-
$class . ' - not in self::$whitelist'
54+
'Config::factory() - could not instantiate ' . $class . ' - not in self::$whitelist'
5855
);
5956
}
6057
}

Config/ConfigTimer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ public function setConfig($file)
9898
}
9999
$config[$timerKey] = $tmpConf;
100100
}
101-
102101
}
103102

104103
$this->setByArray($config);

Tests/Timer/TimerTest.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
/**
1717
* Class TimerTest
18+
*
1819
* @package Asm\Tests\Timer
1920
* @author marc aschmann <[email protected]>
2021
*/
@@ -29,7 +30,7 @@ public function testConstruct()
2930
{
3031
$config = Config::factory(
3132
array(
32-
'file' => TestData::getYamlTimerConfigFile(),
33+
'file' => TestData::getYamlTimerConfigFile(),
3334
'filecheck' => false,
3435
),
3536
'ConfigTimer'
@@ -44,13 +45,13 @@ public function testConstruct()
4445

4546
/**
4647
* @depends testConstruct
47-
* @covers \Asm\Timer\Timer::isTimerActive
48-
* @covers \Asm\Timer\Timer::checkDate
49-
* @covers \Asm\Timer\Timer::checkIntervals
50-
* @covers \Asm\Timer\Timer::checkDays
51-
* @covers \Asm\Timer\Timer::checkTime
52-
* @covers \Asm\Timer\Timer::checkHoliday
53-
* @covers \Asm\Timer\Timer::flush
48+
* @covers \Asm\Timer\Timer::isTimerActive
49+
* @covers \Asm\Timer\Timer::checkDate
50+
* @covers \Asm\Timer\Timer::checkIntervals
51+
* @covers \Asm\Timer\Timer::checkDays
52+
* @covers \Asm\Timer\Timer::checkTime
53+
* @covers \Asm\Timer\Timer::checkHoliday
54+
* @covers \Asm\Timer\Timer::flush
5455
* @param Timer $timer
5556
*/
5657
public function testIsTimerActive(Timer $timer)
@@ -70,16 +71,19 @@ public function testIsTimerActive(Timer $timer)
7071

7172
/**
7273
* @depends testConstruct
73-
* @covers \Asm\Timer\Timer::isHoliday
74-
* @covers \Asm\Timer\Timer::checkHoliday
74+
* @covers \Asm\Timer\Timer::isHoliday
75+
* @covers \Asm\Timer\Timer::getHoliday
76+
* @covers \Asm\Timer\Timer::checkHoliday
7577
* @param Timer $timer
7678
*/
7779
public function testIsHoliday(Timer $timer)
7880
{
79-
$currentYear = date('Y');
81+
$currentYear = date('Y');
8082

8183
$this->assertFalse($timer->isHoliday('2014-03-03 00:00:00'), 'failed to check non-holiday date');
8284
$this->assertTrue($timer->isHoliday($currentYear . '-12-24 12:30:01'), 'failed to validate christmas');
85+
$this->assertNotEmpty($timer->getHoliday());
86+
8387
$this->assertTrue(is_bool($timer->isHoliday()), 'failed to validate bool return');
8488
}
8589
}

Timer/Timer.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ final class Timer
2222
/**
2323
* @var \Asm\Data\Data
2424
*/
25-
private $config = null;
25+
private $config;
2626

2727
/**
28-
* current timer's config
28+
* Current timer's config.
2929
*
30-
* @var array
30+
* @var mixed
3131
*/
32-
private $currentConf = array();
32+
private $currentConf;
3333

3434
/**
35-
* if a holiday is in place - here it is
35+
* If a holiday is in place - here it is.
3636
*
3737
* @var null|\DateTime
3838
*/
39-
private $holiday = null;
39+
private $holiday;
4040

4141
/**
42-
* constructor with dependency injection
42+
* Constructor with dependency injection.
4343
*
4444
* @param ConfigTimer $config
4545
*/
@@ -51,7 +51,7 @@ public function __construct(ConfigTimer $config)
5151
}
5252

5353
/**
54-
* check if timer is active
54+
* Check if timer is active.
5555
*
5656
* @param string $type
5757
* @return boolean
@@ -62,7 +62,7 @@ public function isTimerActive($type)
6262
$this->currentConf = $this->config->get('timers', $type);
6363

6464
// pre-check holidays
65-
if (isset($this->currentConf['holiday'])) {
65+
if (true === isset($this->currentConf['holiday'])) {
6666
// check if general holidays are to be used
6767
if (isset($this->currentConf['holiday']['use_general'])
6868
&& true === (bool)$this->currentConf['holiday']['use_general']
@@ -85,7 +85,7 @@ public function isTimerActive($type)
8585
}
8686

8787
/**
88-
* calculate difference between holiday DateTime objects and current or given time
88+
* Calculate difference between holiday DateTime objects and current or given time.
8989
*
9090
* @param string|null $date
9191
* @return boolean
@@ -96,7 +96,7 @@ public function isHoliday($date = null)
9696
}
9797

9898
/**
99-
* returns holiday object, if set
99+
* Returns holiday object, if set.
100100
*
101101
* @codeCoverageIgnore
102102
* @return \DateTime|null
@@ -107,7 +107,7 @@ public function getHoliday()
107107
}
108108

109109
/**
110-
* clear current configuration
110+
* Clear current configuration.
111111
*/
112112
public function flush()
113113
{
@@ -116,7 +116,7 @@ public function flush()
116116
}
117117

118118
/**
119-
* date checks on config
119+
* Date checks on config.
120120
*
121121
* @return bool
122122
*/
@@ -148,7 +148,7 @@ private function checkDate()
148148
}
149149

150150
/**
151-
* check for holidays
151+
* Check for holidays.
152152
*
153153
* @param string|null $date
154154
* @return bool
@@ -218,7 +218,7 @@ private function checkHoliday($date = null)
218218
}
219219

220220
/**
221-
* check if current date is in interval
221+
* Check if current date is in interval.
222222
*
223223
* @param array $intervals
224224
* @return bool
@@ -249,7 +249,7 @@ private function checkIntervals(array $intervals = array())
249249
}
250250

251251
/**
252-
* check if today is in days array
252+
* Check if today is in days array.
253253
*
254254
* @return bool
255255
*/
@@ -265,7 +265,7 @@ private function checkDays()
265265
}
266266

267267
/**
268-
* do time comparison
268+
* Do time comparison.
269269
*
270270
* @param array $intervals
271271
* @return bool

0 commit comments

Comments
 (0)