- setWorkingDaysInMonth
+ setWorkingDaysInMonth
100.00% covered (success)
@@ -337,9 +337,9 @@
private function getEasterDatetime ( $year )
{
-
$base = new \ DateTime ( " $year -03-21 " ) ;
-
$days = easter_days ( $year ) ;
-
return $base -> add ( new \ DateInterval ( " P { $days } D " ) ) ;
+
$base = new \ DateTime ( " $year -03-21 " ) ;
+
$days = easter_days ( $year ) ;
+
return $base -> add ( new \ DateInterval ( " P { $days } D " ) ) ;
}
@@ -350,11 +350,11 @@
protected function readTypeFromJsonFileUniversal ( $filePath , $fileBaseName )
{
-
$fName = __DIR__ . DIRECTORY_SEPARATOR . $filePath . DIRECTORY_SEPARATOR . $fileBaseName . '.min.json' ;
-
$fJson = fopen ( $fName , 'r' ) ;
-
$jSonContent = fread ( $fJson , filesize ( $fName ) ) ;
-
fclose ( $fJson ) ;
-
return json_decode ( $jSonContent , true ) ;
+
$fName = $filePath . DIRECTORY_SEPARATOR . $fileBaseName . '.min.json' ;
+
$fJson = fopen ( $fName , 'r' ) ;
+
$jSonContent = fread ( $fJson , filesize ( $fName ) ) ;
+
fclose ( $fJson ) ;
+
return json_decode ( $jSonContent , true ) ;
}
@@ -366,21 +366,21 @@
protected function setHolidays ( \ DateTime $lngDate , $inclCatholicEaster = false , $inclWorkingHolidays = false )
{
-
$givenYear = $lngDate -> format ( 'Y' ) ;
-
$daying = array_merge ( $this -> setHolidaysOrthodoxEaster ( $lngDate ) , $this -> setHolidaysFixed ( $lngDate ) ) ;
-
if ( $inclWorkingHolidays ) {
-
$daying = array_merge ( $daying , $this -> setHolidaysFixedButWorking ( $lngDate ) ) ;
+
$givenYear = $lngDate -> format ( 'Y' ) ;
+
$daying = array_merge ( $this -> setHolidaysOrthodoxEaster ( $lngDate ) , $this -> setHolidaysFixed ( $lngDate ) ) ;
+
if ( $inclWorkingHolidays ) {
+
$daying = array_merge ( $daying , $this -> setHolidaysFixedButWorking ( $lngDate ) ) ;
}
-
if ( $inclCatholicEaster ) {
-
$firstEasterDate = strtotime ( $this -> getEasterDatetime ( $givenYear ) -> format ( 'Y-m-d' ) ) ;
-
$secondEasterDate = strtotime ( '+1 day' , $firstEasterDate ) ;
-
$daying = array_merge ( $daying , [
-
$firstEasterDate ,
-
$secondEasterDate ,
+
if ( $inclCatholicEaster ) {
+
$firstEasterDate = strtotime ( $this -> getEasterDatetime ( $givenYear ) -> format ( 'Y-m-d' ) ) ;
+
$secondEasterDate = strtotime ( '+1 day' , $firstEasterDate ) ;
+
$daying = array_merge ( $daying , [
+
$firstEasterDate ,
+
$secondEasterDate ,
] ) ;
}
-
sort ( $daying ) ;
-
return array_unique ( $daying ) ;
+
sort ( $daying ) ;
+
return array_unique ( $daying ) ;
}
@@ -392,118 +392,122 @@
private function setHolidaysFixed ( \ DateTime $lngDate )
{
-
$givenYear = $lngDate -> format ( 'Y' ) ;
-
$daying = [
-
mktime ( 0 , 0 , 0 , 1 , 1 , $givenYear ) ,
-
mktime ( 0 , 0 , 0 , 1 , 2 , $givenYear ) ,
-
mktime ( 0 , 0 , 0 , 5 , 1 , $givenYear ) ,
-
mktime ( 0 , 0 , 0 , 12 , 1 , $givenYear ) ,
-
mktime ( 0 , 0 , 0 , 12 , 25 , $givenYear ) ,
-
mktime ( 0 , 0 , 0 , 12 , 26 , $givenYear ) ,
-
] ;
-
if ( $givenYear >= 2009 ) {
-
$daying [ ] = mktime ( 0 , 0 , 0 , 8 , 15 , $givenYear ) ;
-
}
-
if ( $givenYear >= 2012 ) {
-
$daying [ ] = mktime ( 0 , 0 , 0 , 11 , 30 , $givenYear ) ;
-
}
-
sort ( $daying ) ;
-
return $daying ;
-
}
-
-
-
-
-
-
-
-
-
private function setHolidaysFixedButWorking ( \ DateTime $lngDate )
-
{
-
$daying = [ ] ;
-
$givenYear = $lngDate -> format ( 'Y' ) ;
-
if ( $givenYear >= 2015 ) {
-
$daying [ ] = mktime ( 0 , 0 , 0 , 1 , 24 , $givenYear ) ;
-
}
-
if ( $givenYear >= 2016 ) {
-
$daying [ ] = mktime ( 0 , 0 , 0 , 2 , 19 , $givenYear ) ;
+
$daying = [
+
mktime ( 0 , 0 , 0 , 1 , 1 , $lngDate -> format ( 'Y' ) ) ,
+
mktime ( 0 , 0 , 0 , 1 , 2 , $lngDate -> format ( 'Y' ) ) ,
+
mktime ( 0 , 0 , 0 , 5 , 1 , $lngDate -> format ( 'Y' ) ) ,
+
mktime ( 0 , 0 , 0 , 12 , 1 , $lngDate -> format ( 'Y' ) ) ,
+
mktime ( 0 , 0 , 0 , 12 , 25 , $lngDate -> format ( 'Y' ) ) ,
+
mktime ( 0 , 0 , 0 , 12 , 26 , $lngDate -> format ( 'Y' ) ) ,
+
] ;
+
if ( $lngDate -> format ( 'Y' ) >= 2009 ) {
+
$daying [ ] = mktime ( 0 , 0 , 0 , 8 , 15 , $lngDate -> format ( 'Y' ) ) ;
+
if ( $lngDate -> format ( 'Y' ) >= 2012 ) {
+
$daying [ ] = mktime ( 0 , 0 , 0 , 11 , 30 , $lngDate -> format ( 'Y' ) ) ;
+
if ( $lngDate -> format ( 'Y' ) >= 2017 ) {
+
$daying [ ] = mktime ( 0 , 0 , 0 , 1 , 24 , $lngDate -> format ( 'Y' ) ) ;
+
$daying [ ] = mktime ( 0 , 0 , 0 , 6 , 1 , $lngDate -> format ( 'Y' ) ) ;
+
}
+
}
+
}
+
sort ( $daying ) ;
+
return $daying ;
+
}
+
+
+
+
+
+
+
+
+
private function setHolidaysFixedButWorking ( \ DateTime $lngDate )
+
{
+
$daying = [ ] ;
+
$givenYear = $lngDate -> format ( 'Y' ) ;
+
if ( $givenYear >= 2015 ) {
+
$daying [ ] = mktime ( 0 , 0 , 0 , 1 , 24 , $givenYear ) ;
}
-
return $daying ;
-
}
-
-
-
-
-
-
-
-
private function setHolidaysOrthodoxEaster ( \ DateTime $lngDate )
-
{
-
$givenYear = $lngDate -> format ( 'Y' ) ;
-
$daying = [ ] ;
-
$statmentsArray = $this -> readTypeFromJsonFileUniversal ( 'json' , 'RomanianBankHolidays' ) ;
-
if ( array_key_exists ( $givenYear , $statmentsArray ) ) {
-
foreach ( $statmentsArray [ $givenYear ] as $value ) {
-
$daying [ ] = strtotime ( $value ) ;
-
}
-
}
-
return $daying ;
-
}
-
-
-
-
-
-
-
-
-
protected function setHolidaysInMonth ( \ DateTime $lngDate , $inclCatholicEaster = false )
-
{
-
$holidaysInGivenYear = $this -> setHolidays ( $lngDate , $inclCatholicEaster ) ;
-
$thisMonthDayArray = $this -> setMonthAllDaysIntoArray ( $lngDate ) ;
-
$holidays = 0 ;
-
foreach ( $thisMonthDayArray as $value ) {
-
if ( in_array ( $value , $holidaysInGivenYear ) ) {
-
$holidays += 1 ;
-
}
-
}
-
return $holidays ;
-
}
-
-
-
-
-
-
-
-
protected function setMonthAllDaysIntoArray ( \ DateTime $lngDate )
-
{
-
$firstDayGivenMonth = strtotime ( $lngDate -> modify ( 'first day of this month' ) -> format ( 'Y-m-d' ) ) ;
-
$lastDayInGivenMonth = strtotime ( $lngDate -> modify ( 'last day of this month' ) -> format ( 'Y-m-d' ) ) ;
-
$secondsInOneDay = 24 * 60 * 60 ;
-
return range ( $firstDayGivenMonth , $lastDayInGivenMonth , $secondsInOneDay ) ;
-
}
-
-
-
-
-
-
-
-
-
protected function setWorkingDaysInMonth ( \ DateTime $lngDate , $inclCatholicEaster = false )
-
{
-
$holidaysInGivenYear = $this -> setHolidays ( $lngDate , $inclCatholicEaster ) ;
-
$thisMonthDayArray = $this -> setMonthAllDaysIntoArray ( $lngDate ) ;
-
$workingDays = 0 ;
-
foreach ( $thisMonthDayArray as $value ) {
-
if ( ! in_array ( strftime ( '%w' , $value ) , [ 0 , 6 ] ) && ! in_array ( $value , $holidaysInGivenYear ) ) {
-
$workingDays += 1 ;
-
}
-
}
-
return $workingDays ;
-
}
-
}
+
if ( $givenYear >= 2016 ) {
+
$daying [ ] = mktime ( 0 , 0 , 0 , 2 , 19 , $givenYear ) ;
+
}
+
return $daying ;
+
}
+
+
+
+
+
+
+
+
private function setHolidaysOrthodoxEaster ( \ DateTime $lngDate )
+
{
+
$givenYear = $lngDate -> format ( 'Y' ) ;
+
$daying = [ ] ;
+
$configPath = __DIR__ . DIRECTORY_SEPARATOR . 'json' ;
+
$statmentsArray = $this -> readTypeFromJsonFileUniversal ( $configPath , 'RomanianBankHolidays' ) ;
+
if ( array_key_exists ( $givenYear , $statmentsArray ) ) {
+
foreach ( $statmentsArray [ $givenYear ] as $value ) {
+
$daying [ ] = strtotime ( $value ) ;
+
}
+
}
+
return $daying ;
+
}
+
+
+
+
+
+
+
+
+
protected function setHolidaysInMonth ( \ DateTime $lngDate , $inclCatholicEaster = false )
+
{
+
$holidaysInGivenYear = $this -> setHolidays ( $lngDate , $inclCatholicEaster ) ;
+
$thisMonthDayArray = $this -> setMonthAllDaysIntoArray ( $lngDate ) ;
+
$holidays = 0 ;
+
foreach ( $thisMonthDayArray as $value ) {
+
if ( in_array ( $value , $holidaysInGivenYear ) ) {
+
$holidays += 1 ;
+
}
+
}
+
return $holidays ;
+
}
+
+
+
+
+
+
+
+
protected function setMonthAllDaysIntoArray ( \ DateTime $lngDate )
+
{
+
$firstDayGivenMonth = strtotime ( $lngDate -> modify ( 'first day of this month' ) -> format ( 'Y-m-d' ) ) ;
+
$lastDayInGivenMonth = strtotime ( $lngDate -> modify ( 'last day of this month' ) -> format ( 'Y-m-d' ) ) ;
+
$secondsInOneDay = 24 * 60 * 60 ;
+
return range ( $firstDayGivenMonth , $lastDayInGivenMonth , $secondsInOneDay ) ;
+
}
+
+
+
+
+
+
+
+
+
protected function setWorkingDaysInMonth ( \ DateTime $lngDate , $inclCatholicEaster = false )
+
{
+
$holidaysInGivenYear = $this -> setHolidays ( $lngDate , $inclCatholicEaster ) ;
+
$thisMonthDayArray = $this -> setMonthAllDaysIntoArray ( $lngDate ) ;
+
$workingDays = 0 ;
+
foreach ( $thisMonthDayArray as $value ) {
+
if ( ! in_array ( strftime ( '%w' , $value ) , [ 0 , 6 ] ) && ! in_array ( $value , $holidaysInGivenYear ) ) {
+
$workingDays += 1 ;
+
}
+
}
+
return $workingDays ;
+
}
+
}
@@ -516,7 +520,7 @@
Legend
Dead Code
- Generated by php-code-coverage 4.0.1 using PHP 7.0.12 with Xdebug 2.4.1 and PHPUnit 5.5.4 at Wed Oct 19 1:19:26 EEST 2016.
+ Generated by php-code-coverage 4.0.2 using PHP 7.0.13 with Xdebug 2.4.1 and PHPUnit 5.6.5 at Mon Nov 28 11:56:19 EET 2016.
diff --git a/tests/php-unit/coverage.html/dashboard.html b/tests/php-unit/coverage.html/dashboard.html
index 2d0eca2..3ad3fde 100644
--- a/tests/php-unit/coverage.html/dashboard.html
+++ b/tests/php-unit/coverage.html/dashboard.html
@@ -2,7 +2,7 @@
-
Dashboard for D:\Git\GitHub\danielgp.GitHub\bank-holidays\source
+
Dashboard for C:\www\Data\GitRepositories\GitHub\danielgp\bank-holidays\source
@@ -18,7 +18,7 @@
@@ -217,7 +217,7 @@
Project Risks
.showDistY(true)
.showLegend(false)
.forceX([0, 100]);
- chart.tooltipContent(function(key, y, e, graph) {
+ chart.tooltipContent(function(graph) {
return '
' + graph.point.class + '
';
});
@@ -225,7 +225,7 @@
Project Risks
chart.yAxis.axisLabel('Cyclomatic Complexity');
d3.select('#classComplexity svg')
- .datum(getComplexityData([[100,22,"
Romanian<\/a>"]], 'Class Complexity'))
+ .datum(getComplexityData([[100,23," Romanian<\/a>"]], 'Class Complexity'))
.transition()
.duration(500)
.call(chart);
@@ -241,7 +241,7 @@ Project Risks
.showDistY(true)
.showLegend(false)
.forceX([0, 100]);
- chart.tooltipContent(function(key, y, e, graph) {
+ chart.tooltipContent(function(graph) {
return '' + graph.point.class + '
';
});
@@ -249,7 +249,7 @@ Project Risks
chart.yAxis.axisLabel('Method Complexity');
d3.select('#methodComplexity svg')
- .datum(getComplexityData([[100,1," Romanian::getEasterDatetime<\/a>"],[100,1," Romanian::readTypeFromJsonFileUniversal<\/a>"],[100,3," Romanian::setHolidays<\/a>"],[100,3," Romanian::setHolidaysFixed<\/a>"],[100,3," Romanian::setHolidaysFixedButWorking<\/a>"],[100,3," Romanian::setHolidaysOrthodoxEaster<\/a>"],[100,3," Romanian::setHolidaysInMonth<\/a>"],[100,1," Romanian::setMonthAllDaysIntoArray<\/a>"],[100,4," Romanian::setWorkingDaysInMonth<\/a>"]], 'Method Complexity'))
+ .datum(getComplexityData([[100,1," Romanian::getEasterDatetime<\/a>"],[100,1," Romanian::readTypeFromJsonFileUniversal<\/a>"],[100,3," Romanian::setHolidays<\/a>"],[100,4," Romanian::setHolidaysFixed<\/a>"],[100,3," Romanian::setHolidaysFixedButWorking<\/a>"],[100,3," Romanian::setHolidaysOrthodoxEaster<\/a>"],[100,3," Romanian::setHolidaysInMonth<\/a>"],[100,1," Romanian::setMonthAllDaysIntoArray<\/a>"],[100,4," Romanian::setWorkingDaysInMonth<\/a>"]], 'Method Complexity'))
.transition()
.duration(500)
.call(chart);
diff --git a/tests/php-unit/coverage.html/index.html b/tests/php-unit/coverage.html/index.html
index 373b1c0..7cec8f0 100644
--- a/tests/php-unit/coverage.html/index.html
+++ b/tests/php-unit/coverage.html/index.html
@@ -2,7 +2,7 @@
- Code Coverage for D:\Git\GitHub\danielgp.GitHub\bank-holidays\source
+ Code Coverage for C:\www\Data\GitRepositories\GitHub\danielgp\bank-holidays\source
@@ -17,7 +17,7 @@
- D:\Git\GitHub\danielgp.GitHub\bank-holidays\source
+ C:\www\Data\GitRepositories\GitHub\danielgp\bank-holidays\source
(Dashboard )
@@ -49,7 +49,7 @@
100.00%
- 65 / 65
+ 68 / 68
100.00% covered (success)
@@ -77,7 +77,7 @@
100.00%
- 65 / 65
+ 68 / 68
diff --git a/tests/php-unit/junit.xml b/tests/php-unit/junit.xml
index 3206c0c..441766e 100644
--- a/tests/php-unit/junit.xml
+++ b/tests/php-unit/junit.xml
@@ -1,22 +1,23 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/php-unit/testdox.html b/tests/php-unit/testdox.html
index 04efc83..8a86db2 100644
--- a/tests/php-unit/testdox.html
+++ b/tests/php-unit/testdox.html
@@ -1,50 +1,51 @@
-
-
-
-
-
Test Documentation
-
-
-
-
Romanian
-
- ✓ Holidays fixed but working included
- ✓ Holidays easter 2015 catholic easter first day
- ✓ Holidays easter 2015 catholic easter second day
- ✓ Holidays easter 2015 first day of year
- ✓ Holidays easter 2015 last day of year
- ✓ Holidays easter 2015 orthodox easter first day
- ✓ Holidays easter 2015 orthodox easter second day
- ✓ Holidays in month for month with catholic easter
- ✓ Holidays in month for month without catholic easter
- ✓ Working days in month for month of 19 days
- ✓ Working days in month for month of 20 days
- ✓ Working days in month for month of 20 days with catholic easter
- ✓ Working days in month for month of 21 days
- ✓ Working days in month for month of 22 days
- ✓ Working days in month for month of 23 days
-
-
+
+
+
+
+
Test Documentation
+
+
+
+
Romanian
+
+ ✓ Holidays easter 2015 catholic easter first day
+ ✓ Holidays easter 2015 catholic easter second day
+ ✓ Holidays easter 2015 first day of year
+ ✓ Holidays easter 2015 last day of year
+ ✓ Holidays easter 2015 orthodox easter first day
+ ✓ Holidays easter 2015 orthodox easter second day
+ ✓ Holidays fixed but working included
+ ✓ Holidays fixed new in 2017
+ ✓ Holidays in month for month with catholic easter
+ ✓ Holidays in month for month without catholic easter
+ ✓ Working days in month for month of 19 days
+ ✓ Working days in month for month of 20 days
+ ✓ Working days in month for month of 20 days with catholic easter
+ ✓ Working days in month for month of 21 days
+ ✓ Working days in month for month of 22 days
+ ✓ Working days in month for month of 23 days
+
+
\ No newline at end of file
diff --git a/tests/php-unit/testdox.txt b/tests/php-unit/testdox.txt
index ea59ae2..0f4bbdb 100644
--- a/tests/php-unit/testdox.txt
+++ b/tests/php-unit/testdox.txt
@@ -1,17 +1,18 @@
-Romanian
- [x] Holidays fixed but working included
- [x] Holidays easter 2015 catholic easter first day
- [x] Holidays easter 2015 catholic easter second day
- [x] Holidays easter 2015 first day of year
- [x] Holidays easter 2015 last day of year
- [x] Holidays easter 2015 orthodox easter first day
- [x] Holidays easter 2015 orthodox easter second day
- [x] Holidays in month for month with catholic easter
- [x] Holidays in month for month without catholic easter
- [x] Working days in month for month of 19 days
- [x] Working days in month for month of 20 days
- [x] Working days in month for month of 20 days with catholic easter
- [x] Working days in month for month of 21 days
- [x] Working days in month for month of 22 days
- [x] Working days in month for month of 23 days
-
+Romanian
+ [x] Holidays easter 2015 catholic easter first day
+ [x] Holidays easter 2015 catholic easter second day
+ [x] Holidays easter 2015 first day of year
+ [x] Holidays easter 2015 last day of year
+ [x] Holidays easter 2015 orthodox easter first day
+ [x] Holidays easter 2015 orthodox easter second day
+ [x] Holidays fixed but working included
+ [x] Holidays fixed new in 2017
+ [x] Holidays in month for month with catholic easter
+ [x] Holidays in month for month without catholic easter
+ [x] Working days in month for month of 19 days
+ [x] Working days in month for month of 20 days
+ [x] Working days in month for month of 20 days with catholic easter
+ [x] Working days in month for month of 21 days
+ [x] Working days in month for month of 22 days
+ [x] Working days in month for month of 23 days
+