<?php
declare(strict_types=1);

function ysp_app_files(string $baseDir): array {
  $files = [
    $baseDir . '/index.html',
    $baseDir . '/api.php',
    $baseDir . '/.htaccess',
    $baseDir . '/assets/css/app.css',
    $baseDir . '/assets/js/app.js',
  ];
  foreach (glob($baseDir . '/.lib/*.php') ?: [] as $file) {
    $files[] = $file;
  }
  return array_values(array_unique($files));
}

function ysp_app_version(string $baseDir): string {
  $mtime = 0;
  foreach (ysp_app_files($baseDir) as $file) {
    if (is_file($file)) {
      $mtime = max($mtime, (int)filemtime($file));
    }
  }
  return (string)$mtime;
}
