MimeMap

BaseMap
in package
implements MapInterface

AbstractYes

Abstract base class for managing MimeMap maps.

This class cannot be instantiated.

Tags
template
implements

Table of Contents

Interfaces

MapInterface
Interface for maps.

Properties

$backupMap  : TMap|null
A backup of the mapping between file extensions and MIME types.
$instance  : MapInterface<string|int, TMap>|null
Singleton instance.
$map  : TMap
Mapping between file extensions and MIME types.

Methods

__construct()  : mixed
Constructor.
backup()  : void
Backs up the map array.
getFileName()  : string
Returns the map's class fully qualified filename.
getInstance()  : MapInterface<string|int, TMap>
Returns the singleton.
getMapArray()  : TMap
Gets the map array.
reset()  : void
Resets the map array to the backup.
sort()  : MapInterface<string|int, TMap>
Sorts the map.
addMapSubEntry()  : MapInterface<string|int, TMap>
Adds an entry to the map.
getMapEntry()  : array<string, array<string|int, string>>
Gets the content of an entry of the map.
getMapSubEntry()  : array<int<0, max>, string>
Gets the content of a subentry of the map.
listEntries()  : array<int, int|string>
Gets a list of entries of the map.
removeMapSubEntry()  : bool
Removes an entry from the map.
setValueAsDefault()  : MapInterface<string|int, TMap>
Sets a value as the default for an entry.

Properties

$backupMap

A backup of the mapping between file extensions and MIME types.

protected static TMap|null $backupMap

Used during the map update process.

$map

Mapping between file extensions and MIME types.

protected static TMap $map = []

Methods

__construct()

Constructor.

public __construct() : mixed

backup()

Backs up the map array.

public backup() : void

getFileName()

Returns the map's class fully qualified filename.

public getFileName() : string
Return values
string

getMapArray()

Gets the map array.

public getMapArray() : TMap
Return values
TMap

reset()

Resets the map array to the backup.

public reset() : void

addMapSubEntry()

Adds an entry to the map.

protected addMapSubEntry(string $entry, string $entryKey, string $subEntry, string $value) : MapInterface<string|int, TMap>

Checks that no duplicate entries are made.

Parameters
$entry : string

The main array entry.

$entryKey : string

The main entry value.

$subEntry : string

The sub entry.

$value : string

The value to add.

Return values
MapInterface<string|int, TMap>

getMapEntry()

Gets the content of an entry of the map.

protected getMapEntry(string $entry, string $entryKey) : array<string, array<string|int, string>>
Parameters
$entry : string

The main array entry.

$entryKey : string

The main entry value.

Return values
array<string, array<string|int, string>>

The values of the entry, or empty array if missing.

getMapSubEntry()

Gets the content of a subentry of the map.

protected getMapSubEntry(string $entry, string $entryKey, string $subEntry) : array<int<0, max>, string>
Parameters
$entry : string

The main array entry.

$entryKey : string

The main entry value.

$subEntry : string

The sub entry.

Return values
array<int<0, max>, string>

The values of the subentry, or empty array if missing.

listEntries()

Gets a list of entries of the map.

protected listEntries(string $entry[, string|null $match = null ]) : array<int, int|string>
Parameters
$entry : string

The main array entry.

$match : string|null = null

(Optional) a match wildcard to limit the list.

Return values
array<int, int|string>

The list of the entries.

removeMapSubEntry()

Removes an entry from the map.

protected removeMapSubEntry(string $entry, string $entryKey, string $subEntry, string $value) : bool
Parameters
$entry : string

The main array entry.

$entryKey : string

The main entry value.

$subEntry : string

The sub entry.

$value : string

The value to remove.

Return values
bool

true if the entry was removed, false if the entry was not present.

setValueAsDefault()

Sets a value as the default for an entry.

protected setValueAsDefault(string $entry, string $entryKey, string $subEntry, string $value) : MapInterface<string|int, TMap>
Parameters
$entry : string

The main array entry.

$entryKey : string

The main entry value.

$subEntry : string

The sub entry.

$value : string

The value to add.

Tags
throws
MappingException

if no mapping found.

Return values
MapInterface<string|int, TMap>

        
On this page

Search results