Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #30 from tvlooy/psr

Psr
  • Loading branch information...
commit eb46d71fa563d702b21a1647f9812f23139c37e8 2 parents d668b99 + ade0fc3
@mtdowling authored
View
10 src/Cron/AbstractField.php
@@ -2,8 +2,6 @@
namespace Cron;
-use InvalidArgumentException;
-
/**
* Abstract CRON expression field
*
@@ -15,7 +13,7 @@
* Check to see if a field is satisfied by a value
*
* @param string $dateValue Date value to check
- * @param string $value Value to test
+ * @param string $value Value to test
*
* @return bool
*/
@@ -23,7 +21,7 @@ public function isSatisfied($dateValue, $value)
{
if ($this->isIncrementsOfRanges($value)) {
return $this->isInIncrementsOfRanges($dateValue, $value);
- } else if ($this->isRange($value)) {
+ } elseif ($this->isRange($value)) {
return $this->isInRange($dateValue, $value);
}
@@ -58,7 +56,7 @@ public function isIncrementsOfRanges($value)
* Test if a value is within a range
*
* @param string $dateValue Set date value
- * @param string $value Value to test
+ * @param string $value Value to test
*
* @return bool
*/
@@ -73,7 +71,7 @@ public function isInRange($dateValue, $value)
* Test if a value is within an increments of ranges (offset[-to]/step size)
*
* @param string $dateValue Set date value
- * @param string $value Value to test
+ * @param string $value Value to test
*
* @return bool
*/
View
35 src/Cron/CronExpression.php
@@ -2,7 +2,6 @@
namespace Cron;
-use DateInterval;
use DateTime;
use DateTimeZone;
use RuntimeException;
@@ -82,7 +81,7 @@ public static function factory($expression, FieldFactory $fieldFactory = null)
/**
* Parse a CRON expression
*
- * @param string $expression CRON expression (e.g. '8 * * * *')
+ * @param string $expression CRON expression (e.g. '8 * * * *')
* @param FieldFactory $fieldFactory Factory to create cron fields
*/
public function __construct($expression, FieldFactory $fieldFactory)
@@ -118,8 +117,8 @@ public function setExpression($value)
/**
* Set part of the CRON expression
*
- * @param int $position The position of the CRON expression to set
- * @param string $value The value to set
+ * @param int $position The position of the CRON expression to set
+ * @param string $value The value to set
*
* @return CronExpression
* @throws InvalidArgumentException if the value is not valid for the part
@@ -141,7 +140,7 @@ public function setPart($position, $value)
* Get a next run date relative to the current date or a specific date
*
* @param string|DateTime $currentTime (optional) Relative calculation date
- * @param int $nth (optional) Number of matches to skip before returning a
+ * @param int $nth (optional) Number of matches to skip before returning a
* matching next run date. 0, the default, will return the current
* date and time if the next run date falls on the current date and
* time. Setting this value to 1 will skip the first match and go to
@@ -161,9 +160,9 @@ public function getNextRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate
/**
* Get a previous run date relative to the current date or a specific date
*
- * @param string|DateTime $currentTime (optional) Relative calculation date
- * @param int $nth (optional) Number of matches to skip before returning
- * @param bool $allowCurrentDate (optional) Set to TRUE to return the
+ * @param string|DateTime $currentTime (optional) Relative calculation date
+ * @param int $nth (optional) Number of matches to skip before returning
+ * @param bool $allowCurrentDate (optional) Set to TRUE to return the
* current date if it matches the cron expression
*
* @return DateTime
@@ -178,10 +177,10 @@ public function getPreviousRunDate($currentTime = 'now', $nth = 0, $allowCurrent
/**
* Get multiple run dates starting at the current date or a specific date
*
- * @param int $total Set the total number of dates to calculate
- * @param string|DateTime $currentTime (optional) Relative calculation date
- * @param bool $invert (optional) Set to TRUE to retrieve previous dates
- * @param bool $allowCurrentDate (optional) Set to TRUE to return the
+ * @param int $total Set the total number of dates to calculate
+ * @param string|DateTime $currentTime (optional) Relative calculation date
+ * @param bool $invert (optional) Set to TRUE to retrieve previous dates
+ * @param bool $allowCurrentDate (optional) Set to TRUE to return the
* current date if it matches the cron expression
*
* @return array Returns an array of run dates
@@ -209,7 +208,7 @@ public function getExpression($part = null)
{
if (null === $part) {
return implode(' ', $this->cronParts);
- } else if (array_key_exists($part, $this->cronParts)) {
+ } elseif (array_key_exists($part, $this->cronParts)) {
return $this->cronParts[$part];
}
@@ -240,7 +239,7 @@ public function isDue($currentTime = null)
if (null === $currentTime || 'now' === $currentTime) {
$currentDate = date('Y-m-d H:i');
$currentTime = strtotime($currentDate);
- } else if ($currentTime instanceof DateTime) {
+ } elseif ($currentTime instanceof DateTime) {
$currentDate = $currentTime->format('Y-m-d H:i');
$currentTime = strtotime($currentDate);
} else {
@@ -256,10 +255,10 @@ public function isDue($currentTime = null)
/**
* Get the next or previous run date of the expression relative to a date
*
- * @param string|DateTime $currentTime (optional) Relative calculation date
- * @param int $nth (optional) Number of matches to skip before returning
- * @param bool $invert (optional) Set to TRUE to go backwards in time
- * @param bool $allowCurrentDate (optional) Set to TRUE to return the
+ * @param string|DateTime $currentTime (optional) Relative calculation date
+ * @param int $nth (optional) Number of matches to skip before returning
+ * @param bool $invert (optional) Set to TRUE to go backwards in time
+ * @param bool $allowCurrentDate (optional) Set to TRUE to return the
* current date if it matches the cron expression
*
* @return DateTime
View
3  src/Cron/DayOfMonthField.php
@@ -3,7 +3,6 @@
namespace Cron;
use DateTime;
-use DateInterval;
/**
* Day of month field. Allows: * , / - ? L W
@@ -30,7 +29,7 @@ class DayOfMonthField extends AbstractField
*
* @param int $currentYear Current year
* @param int $currentYear Current month
- * @param int $targetDay Target day of the month
+ * @param int $targetDay Target day of the month
*
* @return DateTime Returns the nearest date
*/
View
5 src/Cron/DayOfWeekField.php
@@ -3,7 +3,6 @@
namespace Cron;
use DateTime;
-use DateInterval;
use InvalidArgumentException;
/**
@@ -91,7 +90,7 @@ public function isSatisfiedBy(DateTime $date, $value)
$parts = explode('-', $value);
if ($parts[0] == '7') {
$parts[0] = '0';
- } else if ($parts[1] == '0') {
+ } elseif ($parts[1] == '0') {
$parts[1] = '7';
}
$value = implode('-', $parts);
@@ -111,7 +110,7 @@ public function increment(DateTime $date, $invert = false)
{
if ($invert) {
$date->modify('-1 day');
- $date->setTime(23, 59, 0);
+ $date->setTime(23, 59, 0);
} else {
$date->modify('+1 day');
$date->setTime(0, 0, 0);
View
14 src/Cron/FieldInterface.php
@@ -14,23 +14,23 @@
/**
* Check if the respective value of a DateTime field satisfies a CRON exp
*
- * @param DateTime $date DateTime object to check
- * @param string $value CRON expression to test against
+ * @param DateTime $date DateTime object to check
+ * @param string $value CRON expression to test against
*
* @return bool Returns TRUE if satisfied, FALSE otherwise
*/
- function isSatisfiedBy(DateTime $date, $value);
+ public function isSatisfiedBy(DateTime $date, $value);
/**
* When a CRON expression is not satisfied, this method is used to increment
* or decrement a DateTime object by the unit of the cron field
*
- * @param DateTime $date DateTime object to change
- * @param bool $invert (optional) Set to TRUE to decrement
+ * @param DateTime $date DateTime object to change
+ * @param bool $invert (optional) Set to TRUE to decrement
*
* @return FieldInterface
*/
- function increment(DateTime $date, $invert = false);
+ public function increment(DateTime $date, $invert = false);
/**
* Validates a CRON expression for a given field
@@ -39,5 +39,5 @@ function increment(DateTime $date, $invert = false);
*
* @return bool Returns TRUE if valid, FALSE otherwise
*/
- function validate($value);
+ public function validate($value);
}
View
1  src/Cron/HoursField.php
@@ -3,7 +3,6 @@
namespace Cron;
use DateTime;
-use DateInterval;
use DateTimeZone;
/**
View
1  src/Cron/MinutesField.php
@@ -3,7 +3,6 @@
namespace Cron;
use DateTime;
-use DateInterval;
/**
* Minutes field. Allows: * , / -
View
1  src/Cron/MonthField.php
@@ -3,7 +3,6 @@
namespace Cron;
use DateTime;
-use DateInterval;
/**
* Month field. Allows: * , / -
View
1  src/Cron/YearField.php
@@ -3,7 +3,6 @@
namespace Cron;
use DateTime;
-use DateInterval;
/**
* Year field. Allows: * , / -
View
1  tests/Cron/AbstractFieldTest.php
@@ -2,7 +2,6 @@
namespace Cron\Tests;
-use Cron\CronExpression;
use Cron\DayOfWeekField;
/**
View
2  tests/Cron/CronExpressionTest.php
@@ -195,7 +195,7 @@ public function testDeterminesIfCronIsDue($schedule, $relativeTime, $nextRun, $i
$cron = CronExpression::factory($schedule);
if (is_string($relativeTime)) {
$relativeTime = new DateTime($relativeTime);
- } else if (is_int($relativeTime)) {
+ } elseif (is_int($relativeTime)) {
$relativeTime = date('Y-m-d H:i:s', $relativeTime);
}
$this->assertEquals($isDue, $cron->isDue($relativeTime));
Please sign in to comment.
Something went wrong with that request. Please try again.