1 <?php
declare(strict_types
=1);
3 require_once('common.php');
5 $taskMatrix = require 'taskMatrix.php';
6 $monday = turnBackTime(new DateTimeImmutable
);
8 $extractTasks = function($tasks, $path) {
9 return array_merge($tasks, file_exists($path) ?
lines(trim(file_get_contents($path))) : []);
12 $unfinishedForYear = array_diff(
14 function($season) use ($taskMatrix) {
15 return getTasksForTheSeason($season, $taskMatrix);
17 )(['summer', 'autumn', 'winter', 'spring'])),
18 array_reduce(getFilePathsForYear($monday->year
, PATH_TO_TASKS_FILES
), $extractTasks, [])
21 $unfinishedForSeason = array_diff(
22 getTasksForTheSeason($monday->season
, $taskMatrix),
23 array_reduce(getFilePathsForSeason($monday->year
, $monday->season
, PATH_TO_TASKS_FILES
), $extractTasks, [])
26 $unfinishedForMonth = array_diff(
27 getTasksForTheMonth($monday->month
, $taskMatrix),
28 array_reduce(getFilePathsForMonth($monday->year
, $monday->month
, PATH_TO_TASKS_FILES
), $extractTasks, [])
31 $filePathForWeek = getFilePathForWeek($monday->year
, $monday->month
, $monday->weekNum
, PATH_TO_TASKS_FILES
);
32 $unfinishedForWeek = array_diff(
33 getTasksForTheWeek($monday->year
, $monday->month
, $monday->weekNum
, $taskMatrix),
34 file_exists($filePathForWeek) ?
lines(trim(file_get_contents($filePathForWeek))) : []
37 //EOY => (EOM & EOW) & !EOSx
38 //EOS => (EOM & EOW) & !EOY
39 $taskLists = array_merge(
40 isEndOfYear($monday->year
, $monday->month
, $monday->dayNum
) ?
[unlines(map(getString
)($unfinishedForYear))] : [],
41 isEndOfSeason($monday->year
, $monday->month
, $monday->dayNum
) ?
[unlines(map(getString
)($unfinishedForSeason))] : [],
42 isEndOfMonth($monday->year
, $monday->month
, $monday->dayNum
) ?
[unlines(map(getString
)($unfinishedForMonth))] : [],
43 [unlines(map(getString
)($unfinishedForWeek))]
46 $seasonName = ucfirst($monday->season
);
47 $goodOrBad = function($string, $goodOrBad) {
48 return getString($string . ($goodOrBad ?
'' : 'Good'));
52 [$goodOrBad('endOfWeek', $unfinishedForWeek)],
54 $goodOrBad('endOfMonth', $unfinishedForMonth),
55 $goodOrBad('andAlsoEndOfWeek', $unfinishedForWeek)
58 $goodOrBad('endOf' . $seasonName, $unfinishedForSeason),
59 $goodOrBad('andAlsoEndOfMonth', $unfinishedForMonth),
60 $goodOrBad('finallyEndOfWeek', $unfinishedForWeek)
63 $goodOrBad('endOfYear', $unfinishedForYear),
64 $goodOrBad('andAlsoEndOfMonth', $unfinishedForMonth),
65 $goodOrBad('finallyEndOfWeek', $unfinishedForWeek)
70 function($message, $list) {
73 is_array($message) ?
$message : [$message],
78 // Similar magic to tasks.php
80 isEndOfMonth($monday->year
, $monday->month
, $monday->dayNum
) +
81 isEndOfSeason($monday->year
, $monday->month
, $monday->dayNum
) +
82 (isEndOfYear($monday->year
, $monday->month
, $monday->dayNum
) ?
2 : 0) // EOY is independant of EOS, to get the right index need to add 2 instead of 1.
87 foreach ($messages as $message) {
88 sendToGroupChat($message);