ValueBuilder.php
1.33 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
<?php
/**
* A builder wrapping a value that will return upon build.
*
* @package lucatume\DI52
*
* @license GPL-3.0
* Modified by learndash on 06-June-2023 using Strauss.
* @see https://github.com/BrianHenryIE/strauss
*/
namespace StellarWP\Learndash\lucatume\DI52\Builders;
/**
* Class ValueBuilder
*
* @package StellarWP\Learndash\lucatume\DI52\Builders
*/
class ValueBuilder implements BuilderInterface
{
/**
* The value the instance of the builder was built for.
*
* @var mixed
*/
private $value;
/**
* ValueBuilder constructor.
*
* @param mixed $value The value to build the instance of the builder for.
*/
public function __construct($value)
{
$this->value = $value;
}
/**
* Builds and returns an instance of the builder built on the specified value.
*
* @param mixed $value The value the instance of the builder should be built for.
*
* @return ValueBuilder An instance of the builder built on the specified value.
*/
public static function of($value)
{
return $value instanceof self ? $value : new self($value);
}
/**
* Returns the value wrapped by the builder.
*
* @return mixed The value wrapped by the builder.
*/
public function build()
{
return $this->value;
}
}