-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectBuilder.php
More file actions
51 lines (41 loc) · 1.23 KB
/
ObjectBuilder.php
File metadata and controls
51 lines (41 loc) · 1.23 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
<?php
/*
* This file is part of the Klipper package.
*
* (c) François Pluchino <francois.pluchino@klipper.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Klipper\Component\DefaultValue;
/**
* A builder for creating {@link Block} instances.
*
* @author Francois Pluchino
*/
class ObjectBuilder extends ObjectConfigBuilder implements ObjectBuilderInterface
{
private ObjectFactoryInterface $factory;
/**
* Creates a new object default value builder.
*/
public function __construct(ObjectFactoryInterface $factory, array $options = [])
{
parent::__construct($options);
$this->factory = $factory;
}
public function getObjectFactory(): ObjectFactoryInterface
{
return $this->factory;
}
public function getObject(): object
{
if (null === $this->getData()) {
$this->setData($this->getType()->newInstance($this, $this->getOptions()));
}
$this->getType()->buildObject($this, $this->getOptions());
$this->getType()->finishObject($this, $this->getOptions());
$this->getObjectConfig();
return $this->data;
}
}