Skip to content
Snippets Groups Projects

Audio Record Index

Merged Laurent requested to merge audio-record-index into master
Compare and
+ 240
56
Preferences
Compare changes
Files
+ 84
0
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* AFI-OPAC 2.0 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_File_Info {
protected
$_filepath,
$_path_info;
/** @param filepath string */
public function __construct($filepath) {
$this->_filepath = (string)$filepath;
$this->_path_info = $this->_filepath
? pathinfo($this->_filepath)
: ['dirname' => '',
'basename' => '',
'filename' => '',
'extension' => ''];
}
public function humanizeFilename() {
if (!$file = $this->fileNameWithoutExtension())
return '';
$parts = array_filter(preg_split('/[0-9_\*\-\s]+/', $file));
return ucfirst(implode(' ', array_map('trim',$parts)));
}
/**
* @return string
*/
public function fileNameWithoutExtension() {
return $this->_path_info['filename'];
}
/**
* @return string
*/
public function fileNameWithExtension() {
return $this->_path_info['basename'];
}
/**
* @return string
*/
public function fileExtension() {
return $this->_path_info['extension'];
}
/**
* @return string
*/
public function fileSize() {
return file_exists($this->_filepath)
? filesize($this->_filepath)
: 0;
}
}
?>
\ No newline at end of file