Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Updated to 1.1.2 version
Browse files Browse the repository at this point in the history
  • Loading branch information
josantonius committed Jul 16, 2017
1 parent 8719b2d commit 31e5c84
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 27 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/tests export-ignore
/src/Exception export-ignore
.gitattributes export-ignore
.gitignore export-ignore
CHANGELOG.md export-ignore
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## 1.1.2 - 2017-07-16
* Deleted `Josantonius\MimeType\Exception\MimeTypeException` class.
* Deleted `Josantonius\MimeType\Exception\Exceptions` abstract class.
* Deleted `Josantonius\MimeType\Exception\MimeTypeException->__construct()` method.

## 1.1.1 - 2017-03-18
* Some files were excluded from download and comments and readme files were updated.

Expand Down
16 changes: 11 additions & 5 deletions README-ES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,23 @@ Librería PHP para obtener encabezados MIME y extensiones a partir de ellos.
- [Métodos disponibles](#métodos-disponibles)
- [Uso](#uso)
- [Tests](#tests)
- [Manejador de excepciones](#manejador-de-excepciones)
- [Contribuir](#contribuir)
- [Repositorio](#repositorio)
- [Licencia](#licencia)
- [Copyright](#copyright)

---

<p align="center"><strong>Echa un vistazo al código</strong></p>

<p align="center">
<a href="" title="Echa un vistazo al código">
<img src="https://raw.githubusercontent.com/Josantonius/PHP-Algorithm/master/resources/youtube-thumbnail.jpg">
</a>
</p>

---

### Instalación

La mejor forma de instalar esta extensión es a través de [composer](http://getcomposer.org/download/).
Expand All @@ -40,7 +49,7 @@ También puedes clonar el repositorio completo con Git:

### Requisitos

Esta ĺibrería es soportada por versiones de PHP 5.6 o superiores y es compatible con versiones de HHVM 3.0 o superiores.
Esta biblioteca es soportada por versiones de PHP 5.6 o superiores y es compatible con versiones de HHVM 3.0 o superiores.

### Cómo empezar y ejemplos

Expand Down Expand Up @@ -124,9 +133,6 @@ MimeTypeTest::testGetExtensionFromMimeUndefined();
MimeTypeTest::testGetAll();
```

### Manejador de excepciones

Esta librería utiliza [control de excepciones](src/Exception) que puedes personalizar a tu gusto.
### Contribuir
1. Comprobar si hay incidencias abiertas o abrir una nueva para iniciar una discusión en torno a un fallo o función.
1. Bifurca la rama del repositorio en GitHub para iniciar la operación de ajuste.
Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,23 @@ PHP library for obtain headers MIME.
- [Available Methods](#available-methods)
- [Usage](#usage)
- [Tests](#tests)
- [Exception Handler](#exception-handler)
- [Contribute](#contribute)
- [Repository](#repository)
- [Licensing](#licensing)
- [License](#license)
- [Copyright](#copyright)

---

<p align="center"><strong>Take a look at the code</strong></p>

<p align="center">
<a href="" title="Take a look at the code">
<img src="https://raw.githubusercontent.com/Josantonius/PHP-Algorithm/master/resources/youtube-thumbnail.jpg">
</a>
</p>

---

### Installation

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Expand Down Expand Up @@ -125,9 +134,6 @@ MimeTypeTest::testGetExtensionFromMimeUndefined();
MimeTypeTest::testGetAll();
```

### Exception Handler

This library uses [exception handler](src/Exception) that you can customize.
### Contribute
1. Check for open issues or open a new issue to start a discussion around a bug or feature.
1. Fork the repository on GitHub to start making your changes.
Expand All @@ -141,7 +147,7 @@ This is intended for large and long-lived objects.

All files in this repository were created and uploaded automatically with [Reposgit Creator](https://github.com/Josantonius/BASH-Reposgit).

### Licensing
### License

This project is licensed under **MIT license**. See the [LICENSE](LICENSE) file for more info.

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "josantonius/mimetype",
"version": "1.1.1",
"version": "1.1.2",
"type": "library",
"description": "PHP library for obtain headers MIME.",
"keywords": [
Expand Down
26 changes: 12 additions & 14 deletions src/MimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace Josantonius\MimeType;

# use Josantonius\MimeType\Exception\MimeTypeException;

/**
* Get MIME type and file extensions.
*
Expand All @@ -38,59 +36,59 @@ class MimeType {
*/
protected static function load() {

if (is_null(static::$mimeTypes)) {
if (is_null(self::$mimeTypes)) {

$filepath = __DIR__ . "/resources/mimeTypes.jsond";
$filepath = __DIR__ . '/resources/mimeTypes.jsond';

$jsonFile = file_get_contents($filepath);

$mimeTypes = json_decode($jsonFile, true);

static::$mimeTypes = $mimeTypes['data'];
self::$mimeTypes = $mimeTypes['data'];

unset($mimeTypes);
}

return static::$mimeTypes;
return self::$mimeTypes;
}

/**
* Get MIME type from file extension.
*
* @since 1.0.0
*
* @param string $ext → file extension, e.g. ".html"
* @param string $ext → file extension, e.g. '.html'
*
* @throws MimeTypeException → file extension not found
* @return string → MIME type
*/
public static function getMimeFromExtension($ext) {

static::load();
self::load();

return (isset(static::$mimeTypes[$ext]) ? static::$mimeTypes[$ext] : "undefined");
return (isset(self::$mimeTypes[$ext]) ? self::$mimeTypes[$ext] : 'undefined');
}

/**
* Get file extension from MIME type.
*
* @since 1.0.0
*
* @param string $mime → MIME type, e.g. "text/html"
* @param string $mime → MIME type, e.g. 'text/html'
*
* @throws MimeTypeException → MIME type not found
* @return string → file extension
*/
public static function getExtensionFromMime($mime) {

static::load();
self::load();

if ($index = array_search($mime, static::$mimeTypes)) {
if ($index = array_search($mime, self::$mimeTypes)) {

return $index;
}

return "undefined";
return 'undefined';
}

/**
Expand All @@ -102,6 +100,6 @@ public static function getExtensionFromMime($mime) {
*/
public static function getAll() {

return static::load();
return self::load();
}
}

0 comments on commit 31e5c84

Please sign in to comment.