Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
Less_Mime
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 2
20
0.00% covered (danger)
0.00%
0 / 1
 lookup
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 charsets_lookup
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2/**
3 * Mime lookup
4 *
5 * @private
6 */
7class Less_Mime {
8
9    /**
10     * this map is intentionally incomplete
11     * if you want more, install 'mime' dep
12     * @var array<string,string>
13     */
14    private static $types = [
15        '.htm' => 'text/html',
16        '.html' => 'text/html',
17        '.gif' => 'image/gif',
18        '.jpg' => 'image/jpeg',
19        '.jpeg' => 'image/jpeg',
20        '.png' => 'image/png',
21        '.ttf' => 'application/x-font-ttf',
22        '.otf' => 'application/x-font-otf',
23        '.eot' => 'application/vnd.ms-fontobject',
24        '.woff' => 'application/x-font-woff',
25        '.svg' => 'image/svg+xml',
26    ];
27
28    public static function lookup( $filepath ) {
29        $parts = explode( '.', $filepath );
30        $ext = '.' . strtolower( array_pop( $parts ) );
31
32        return self::$types[$ext] ?? null;
33    }
34
35    public static function charsets_lookup( $type = null ) {
36        // assumes all text types are UTF-8
37        return $type && preg_match( '/^text\//', $type ) ? 'UTF-8' : '';
38    }
39}