-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add DateProcessor #73
Conversation
src/Processor/DateProcessor.php
Outdated
|
||
class DateProcessor | ||
{ | ||
use TagCoverageTrait; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this trait is required here, because this processor won't change any tag, but rather create a new one.
BTW we could use TagSearchTrait
to make sure we find the tag we depend on.
src/Processor/DateProcessor.php
Outdated
$day = null; | ||
$month = null; | ||
$year = null; | ||
foreach ($covered as $tag) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this loop IMO
src/Processor/DateProcessor.php
Outdated
} | ||
} | ||
$entry['month'] = $day . '~' . $month; | ||
$entry['_date'] = new DateTime(date('d/m/Y', strtotime($month . ' ' . $day . ' ' . $year))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- What do you think if we make the
_date
value configurable via constructor? and keep defaults to_date
- I would prefer it to be
DateTimeImmutable
{ | ||
$processor = new DateProcessor(); | ||
$entry = $processor([ | ||
'month' => '"1~" # jan', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should test against 1~jan
, because of this listener's behaviour
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to check it against 1~jan
{ | ||
$processor = new DateProcessor(); | ||
$entry = $processor([ | ||
'month' => 'Jul # "~4"', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as mentioned before, it should test against Jul~4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to check it against Jul~4
Thanks for this PR, What do you think it should be the behaviour for these scenarios? ['month' => 'Jul', 'year' => '2000']; // missing day in month
['month' => '05', 'year'=> '2000']; // invalid month value
['month' => '1~jan', 'year' => '98']; // invalid year
['month' => 'foo', 'year' => 'bar']; // invalid
['month' => '1~jan']; // missing year
['year' => '2000']; // missing month
[]; // missing everything
['_date' => 'I do exist']; // already existing _date a) exception I tend to say |
src/Processor/DateProcessor.php
Outdated
|
||
class DateProcessor | ||
{ | ||
use TagCoverageTrait; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace this trait by TagSearchTrait
, then we can call tagSearch()
to get the real tag name for year
and month
src/Processor/DateProcessor.php
Outdated
$month = null; | ||
$year = null; | ||
foreach ($covered as $tag) { | ||
if ($tag === 'month') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TagSearchTrait->tagSearch()
could be useful here
{ | ||
$processor = new DateProcessor(); | ||
$entry = $processor([ | ||
'month' => '"1~" # jan', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to check it against 1~jan
{ | ||
$processor = new DateProcessor(); | ||
$entry = $processor([ | ||
'month' => 'Jul # "~4"', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to check it against Jul~4
Overall I'm happy 😄 I left some comments before getting this merged |
Codecov Report
@@ Coverage Diff @@
## master #73 +/- ##
============================================
+ Coverage 90.38% 90.68% +0.29%
- Complexity 175 180 +5
============================================
Files 9 10 +1
Lines 468 483 +15
============================================
+ Hits 423 438 +15
Misses 45 45
Continue to review full report at Codecov.
|
thank you @LeJeanbono ! |
Fix #28