@@ -27,6 +27,7 @@ abstract class Parser
|
||||
* @param string $url
|
||||
*
|
||||
* @return \App\Parser|null
|
||||
* @throws \App\Exceptions\UnknownParser
|
||||
*/
|
||||
public static function factory(string $url): ?Parser
|
||||
{
|
||||
@@ -48,4 +49,75 @@ abstract class Parser
|
||||
* @return \App\ParsedHome
|
||||
*/
|
||||
abstract public function parse(): ParsedHome;
|
||||
|
||||
|
||||
/**
|
||||
* @param int $score
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function calculateDPE($score)
|
||||
{
|
||||
if (empty($score)) {
|
||||
return 'Inconnu';
|
||||
}
|
||||
if ($score <= 50) {
|
||||
return 'A';
|
||||
}
|
||||
if ($score >= 51 && $score <= 90) {
|
||||
return 'B';
|
||||
}
|
||||
if ($score >= 91 && $score <= 150) {
|
||||
return 'C';
|
||||
}
|
||||
if ($score >= 151 && $score <= 230) {
|
||||
return 'D';
|
||||
}
|
||||
if ($score >= 231 && $score <= 330) {
|
||||
return 'E';
|
||||
}
|
||||
if ($score >= 331 && $score <= 450) {
|
||||
return 'F';
|
||||
}
|
||||
if ($score > 450) {
|
||||
return 'G';
|
||||
}
|
||||
|
||||
return 'Inconnu';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $score
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function calculateGES($score)
|
||||
{
|
||||
if (empty($score)) {
|
||||
return 'Inconnu';
|
||||
}
|
||||
if ($score <= 5) {
|
||||
return 'A';
|
||||
}
|
||||
if ($score >= 6 && $score <= 10) {
|
||||
return 'B';
|
||||
}
|
||||
if ($score >= 11 && $score <= 20) {
|
||||
return 'C';
|
||||
}
|
||||
if ($score >= 21 && $score <= 35) {
|
||||
return 'D';
|
||||
}
|
||||
if ($score >= 36 && $score <= 55) {
|
||||
return 'E';
|
||||
}
|
||||
if ($score >= 56 && $score <= 80) {
|
||||
return 'F';
|
||||
}
|
||||
if ($score > 80) {
|
||||
return 'G';
|
||||
}
|
||||
|
||||
return 'Inconnu';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user