Browse Source

feat(ci/cd): remove file test

merge-requests/10/merge
JamesRezo 2 years ago
parent
commit
5c7c5e790d
  1. 25
      .gitlab-ci.yml
  2. 73
      supportedversions_fonctions.php

25
.gitlab-ci.yml

@ -1,25 +0,0 @@
default:
image: composer:1.10
before_script:
- composer install
stages:
- lint
- test
lint:
stage: lint
script:
- vendor/bin/phpcs
artifacts:
paths:
- phpcs.txt
- phpcs.xml
test:
stage: test
script:
- vendor/bin/phpunit --colors=never
artifacts:
paths:
- .phpunit.cache

73
supportedversions_fonctions.php

@ -51,6 +51,21 @@ function balise_SUPPORTED_VERSIONS_dist($p) {
*/
class SupportedVersions
{
private const DEFAULT_CONFIG = [
'calendar' =>[
'min_year' => 'P3Y',
'max_year' => 'P5Y',
],
'svg' => [
'margin_left' => 80,
'margin_right' => 50,
'header_height' => 24,
'year_width' => 120,
'branch_height' => 30,
'footer_height' => 24,
],
];
/**
* Configuration du calendrier (SVG, CSS, Dates).
*
@ -122,11 +137,16 @@ class SupportedVersions
*/
protected static function compute() {
// Calendar initialization
$calendar = isset(self::$config['calendar']) ?
self::$config['calendar'] :
self::DEFAULT_CONFIG['calendar']
;
$nowYear = self::$now->format('Y');
self::$minDate = (new DateTime('January 1 '.$nowYear))
->sub(new DateInterval(self::$config['calendar']['min_year']));
->sub(new DateInterval($calendar['min_year']));
self::$maxDate = (new DateTime('January 1 '.$nowYear))
->add(new DateInterval(self::$config['calendar']['max_year']));
->add(new DateInterval($calendar['max_year']));
self::$years = array_map(
function ($year) {
return $year->format('Y-m-d');
@ -273,20 +293,25 @@ class SupportedVersions
* @return int
*/
protected static function dateHorizCoord(DateTime $date) {
$svg = isset(self::$config['svg']) ?
self::$config['svg'] :
self::DEFAULT_CONFIG['svg']
;
$diff = $date->diff(self::$minDate);
if (!$diff->invert) {
return self::$config['svg']['margin_left'];
return $svg['margin_left'];
}
$diff2 = self::$maxDate->diff($date);
if (!$diff2->invert) {
return self::$config['svg']['margin_left'] +
self::width(self::$config['svg']['margin_left']) +
self::$config['svg']['year_width'];
return $svg['margin_left'] +
self::width($svg['margin_left']) +
$svg['year_width'];
}
return self::$config['svg']['margin_left'] +
intval($diff->days / (365.24 / self::$config['svg']['year_width']));
return $svg['margin_left'] +
intval($diff->days / (365.24 / $svg['year_width']));
}
/**
@ -353,6 +378,11 @@ class SupportedVersions
}
// @codeCoverageIgnoreEnd
$svg = isset(self::$config['svg']) ?
self::$config['svg'] :
self::DEFAULT_CONFIG['svg']
;
$branches = array_map(
function ($branch) {
return $branch['branch'];
@ -361,7 +391,7 @@ class SupportedVersions
);
$i = array_search($branch, $branches, true);
return self::$config['svg']['header_height'] + (self::$config['svg']['branch_height'] * $i);
return $svg['header_height'] + ($svg['branch_height'] * $i);
}
/**
@ -378,7 +408,12 @@ class SupportedVersions
self::init();
}
$top = self::top($branch) + (0.5 * self::$config['svg']['branch_height']);
$svg = isset(self::$config['svg']) ?
self::$config['svg'] :
self::DEFAULT_CONFIG['svg']
;
$top = self::top($branch) + (0.5 * $svg['branch_height']);
return intval($top);
}
@ -397,9 +432,14 @@ class SupportedVersions
self::init();
}
$svg = isset(self::$config['svg']) ?
self::$config['svg'] :
self::DEFAULT_CONFIG['svg']
;
return $margin_left +
self::$config['svg']['margin_right'] +
((count(self::$years) - 1) * self::$config['svg']['year_width']);
$svg['margin_right'] +
((count(self::$years) - 1) * $svg['year_width']);
}
/**
@ -416,10 +456,15 @@ class SupportedVersions
self::init();
}
$svg = isset(self::$config['svg']) ?
self::$config['svg'] :
self::DEFAULT_CONFIG['svg']
;
return intval(
$header_height +
self::$config['svg']['footer_height'] +
(count(self::branchesToShow(true)) * self::$config['svg']['branch_height'])
$svg['footer_height'] +
(count(self::branchesToShow(true)) * $svg['branch_height'])
);
}

Loading…
Cancel
Save