-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
39 lines (34 loc) · 807 Bytes
/
functions.php
File metadata and controls
39 lines (34 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
function displayAuthor(string $authorEmail, array $users): string
{
foreach ($users as $user) {
if ($authorEmail === $user['email']) {
return $user['full_name'] . '(' . $user['age'] . ' ans)';
}
}
return 'Auteur inconnu';
}
function isValidRecipe(array $recipe): bool
{
if (array_key_exists('is_enabled', $recipe)) {
$isEnabled = $recipe['is_enabled'];
} else {
$isEnabled = false;
}
return $isEnabled;
}
function getRecipes(array $recipes): array
{
$valid_recipes = [];
foreach ($recipes as $recipe) {
if (isValidRecipe($recipe)) {
$valid_recipes[] = $recipe;
}
}
return $valid_recipes;
}
function redirectToUrl(string $url): never
{
header("Location: {$url}");
exit();
}