Example #1
0
 /**
  * tests if data from filename is valid
  *
  * @dataProvider dateProvider
  *
  * @param string $filename filename with extension
  */
 function testFileDate($filename, $expectedDate)
 {
     $file = new File($filename);
     $this->assertSame($expectedDate, $file->getDate()->format('d.m.Y'));
 }
Example #2
0
<?php

require 'vendor/autoload.php';
require_once 'config.php';
use RadiorecorderApi\File;
use RadiorecorderApi\Duration\SimpleFormatter as DurationFormatter;
use RadiorecorderApi\Size\HumanReadableFormatter as SizeFormatter;
$files = glob('/home/abez/recordings/' . $radiostation_path . '/*');
sort($files);
$recordings = [];
foreach ($files as $path) {
    $file = new File($path);
    $recording = ['size' => $file->getSize()->format(new SizeFormatter()), 'date_time' => $file->getDate()->format('d.m.Y'), 'done' => true, 'filename' => $path, 'duration' => $file->getDuration()->format(new DurationFormatter())];
    $recordings[] = $recording;
}
echo json_encode($recordings);