-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractFacadeType.php
More file actions
53 lines (44 loc) · 1015 Bytes
/
AbstractFacadeType.php
File metadata and controls
53 lines (44 loc) · 1015 Bytes
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
<?php
namespace Bdf\Prime\Types;
use Bdf\Prime\Platform\PlatformInterface;
use Bdf\Prime\Platform\PlatformTypeInterface;
/**
* Abstract class adapter for facade type
*/
abstract class AbstractFacadeType implements FacadeTypeInterface
{
/**
* @var string
*/
protected $type;
/**
* FacadeType constructor.
*
* @param string $type
*/
public function __construct($type)
{
$this->type = $type;
}
/**
* {@inheritdoc}
*/
public function toPlatformType(PlatformInterface $platform): PlatformTypeInterface
{
$registry = $platform->types();
return $registry->get($registry->isNative($this->type) ? $this->type : $this->defaultType());
}
/**
* Get the default type to use, if platform do not supports it
*
* @return string
*/
abstract protected function defaultType();
/**
* {@inheritdoc}
*/
public function name(): string
{
return $this->type;
}
}