-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathAbstractLoader.php
More file actions
96 lines (86 loc) · 2.02 KB
/
AbstractLoader.php
File metadata and controls
96 lines (86 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* This file is part of the m1\vars library
*
* (c) m1 <hello@milescroxford.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package m1/vars
* @version 1.1.0
* @author Miles Croxford <hello@milescroxford.com>
* @copyright Copyright (c) Miles Croxford <hello@milescroxford.com>
* @license http://github.com/m1/vars/blob/master/LICENSE
* @link http://github.com/m1/vars/blob/master/README.MD Documentation
*/
namespace M1\Vars\Loader;
/**
* The abstract loader for loaders to be based on
*
* @since 0.1.0
*/
abstract class AbstractLoader
{
/**
* The content from the entity
*
* @var mixed
*/
protected $content;
/**
* The passed entity to be loaded
*
* @var string
*/
protected string $entity;
/**
* The supported extensions
*
* @var array
*/
public static array $supported = array();
/**
* Construct the loader with the passed entity
*
* @param string $entity The passed entity
*/
public function __construct(string $entity)
{
$this->entity = $entity;
}
/**
* The function what loads the content from the entity
*
* @return mixed
*/
abstract public function load();
/**
* Checks whether the loader supports the file extension
*
* @return bool Does the loader support the file
*/
public function supports(): bool
{
$extension = pathinfo($this->entity, PATHINFO_EXTENSION);
return in_array($extension, static::$supported);
}
/**
* Sets what the loader supports
*
* @param array $supports Set the extensions the loader supports
*/
public function setSupports(array $supports)
{
static::$supported = $supports;
}
/**
* Returns the content
*
* @return mixed The content
*/
public function getContent()
{
return $this->content;
}
}