server/src/app/Libraries/Utils.php
changeset 18 f2a40bbc27f6
parent 4 f55970e41793
child 19 eadaf0b8f02e
equal deleted inserted replaced
17:ac3dc090e987 18:f2a40bbc27f6
     1 <?php
     1 <?php
     2 
       
     3 namespace CorpusParole\Libraries;
     2 namespace CorpusParole\Libraries;
     4 
     3 
     5 /**
     4 /**
     6  * Utilities functions
     5  * Utilities functions
     7  */
     6  */
     8 class Utils {
     7 class Utils {
     9 
     8 
    10     /*
     9     /*
    11      * From http://www.thecave.info/php-get-mime-type-from-file-extension/
    10      * From http://www.thecave.info/php-get-mime-type-from-file-extension/
    12      */
    11      */
    13     public static function get_mimetype($file) {
    12     public static function getMimetype($file) {
    14 
    13 
    15         // our list of mime types
    14         // our list of mime types
    16         $mime_types = array(
    15         $mime_types = array(
    17                 "pdf"=>"application/pdf",
    16                 "pdf"=>"application/pdf",
    18                 "exe"=>"application/octet-stream",
    17                 "exe"=>"application/octet-stream",
    49         $extension = strtolower(end($split_ext));
    48         $extension = strtolower(end($split_ext));
    50 
    49 
    51         return $mime_types[$extension];
    50         return $mime_types[$extension];
    52     }
    51     }
    53 
    52 
    54     public static function process_literal_or_string($val) {
    53     public static function processLiteralOrString($val) {
    55         if(is_null($val)) {
    54         if(is_null($val)) {
    56             return $val;
    55             return $val;
    57         }
    56         }
    58         if($val instanceof Literal) {
    57         if($val instanceof Literal) {
    59             return $val->getValue();
    58             return $val->getValue();