1: <?php
2:
3: namespace PHPixie\Template;
4:
5: class Formats
6: {
7: protected $extensionMap = array();
8:
9: public function __construct($externalFormats = array())
10: {
11: foreach($externalFormats as $format) {
12: foreach($format->handledExtensions() as $extension) {
13: $this->extensionMap[$extension] = $format;
14: }
15: }
16: }
17:
18: public function getByFilename($file) {
19: $extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
20:
21: if(!array_key_exists($extension, $this->extensionMap)) {
22: return null;
23: }
24:
25: return $this->extensionMap[$extension];
26: }
27: }