mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 00:27:30 +00:00
Various code cleanup.
This commit is contained in:
@@ -70,6 +70,8 @@ class ParseDateString
|
||||
|
||||
/**
|
||||
* @throws FireflyException
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.NPathComplexity)
|
||||
*/
|
||||
public function parseDate(string $date): Carbon
|
||||
{
|
||||
@@ -82,7 +84,7 @@ class ParseDateString
|
||||
|
||||
// if regex for YYYY-MM-DD:
|
||||
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])$/';
|
||||
$result = preg_match($pattern, $date);
|
||||
$result = preg_match($pattern, $date);
|
||||
if (false !== $result && 0 !== $result) {
|
||||
return $this->parseDefaultDate($date);
|
||||
}
|
||||
@@ -224,7 +226,7 @@ class ParseDateString
|
||||
|
||||
// verify if correct
|
||||
$pattern = '/[+-]\d+[wqmdy]/';
|
||||
$result = preg_match($pattern, $part);
|
||||
$result = preg_match($pattern, $part);
|
||||
if (0 === $result || false === $result) {
|
||||
app('log')->error(sprintf('Part "%s" does not match regular expression. Will be skipped.', $part));
|
||||
|
||||
@@ -280,7 +282,7 @@ class ParseDateString
|
||||
{
|
||||
// if regex for xxxx-MM-xx:
|
||||
$pattern = '/^xxxx-(0[1-9]|1[012])-xx$/';
|
||||
$result = preg_match($pattern, $date);
|
||||
$result = preg_match($pattern, $date);
|
||||
if (false !== $result && 0 !== $result) {
|
||||
app('log')->debug(sprintf('"%s" is a month range.', $date));
|
||||
|
||||
@@ -308,7 +310,7 @@ class ParseDateString
|
||||
{
|
||||
// if regex for YYYY-xx-xx:
|
||||
$pattern = '/^(19|20)\d\d-xx-xx$/';
|
||||
$result = preg_match($pattern, $date);
|
||||
$result = preg_match($pattern, $date);
|
||||
if (false !== $result && 0 !== $result) {
|
||||
app('log')->debug(sprintf('"%s" is a year range.', $date));
|
||||
|
||||
@@ -336,7 +338,7 @@ class ParseDateString
|
||||
{
|
||||
// if regex for xxxx-MM-DD:
|
||||
$pattern = '/^xxxx-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])$/';
|
||||
$result = preg_match($pattern, $date);
|
||||
$result = preg_match($pattern, $date);
|
||||
if (false !== $result && 0 !== $result) {
|
||||
app('log')->debug(sprintf('"%s" is a month/day range.', $date));
|
||||
|
||||
@@ -351,7 +353,7 @@ class ParseDateString
|
||||
{
|
||||
// if regex for YYYY-xx-DD:
|
||||
$pattern = '/^(19|20)\d\d-xx-(0[1-9]|[12]\d|3[01])$/';
|
||||
$result = preg_match($pattern, $date);
|
||||
$result = preg_match($pattern, $date);
|
||||
if (false !== $result && 0 !== $result) {
|
||||
app('log')->debug(sprintf('"%s" is a day/year range.', $date));
|
||||
|
||||
@@ -366,7 +368,7 @@ class ParseDateString
|
||||
{
|
||||
// if regex for YYYY-MM-xx:
|
||||
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-xx$/';
|
||||
$result = preg_match($pattern, $date);
|
||||
$result = preg_match($pattern, $date);
|
||||
if (false !== $result && 0 !== $result) {
|
||||
app('log')->debug(sprintf('"%s" is a month/year range.', $date));
|
||||
|
||||
|
Reference in New Issue
Block a user