For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 13 and the first side effect is on line 3.
The PSR-1: Basic Coding Standard recommends that a file should either introduce
new symbols, that is classes, functions, constants or similar, or have side effects.
Side effects are anything that executes logic, like for example printing output,
changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state
of an application. It also promotes a cleaner style of programming and makes your code
less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the
PSR-1.
Loading history...
2
namespace WFV\Artisan;
3
defined( 'ABSPATH' ) || die( 'envois' );
4
5
use WFV\Contract\ArtisanInterface;
6
7
/**
8
* Genesis
9
*
10
* @since 0.10.0
11
*
12
*/
13
class Director {
14
15
/**
16
* nātūra
17
*
18
* @since 0.10.0
19
* @access protected
20
* @var array
21
*/
22
protected $aspect = array();
23
24
/**
25
* identitās
26
*
27
* @since 0.10.0
28
* @access protected
29
* @var string
30
*/
31
protected $entity;
32
33
/**
34
* chronica
35
*
36
* @since 0.10.0
37
* @access private
38
* @var array
39
*/
40
private $scribe = array();
41
42
/**
43
* Introduce
44
*
45
* @since 0.10.0
46
*
47
* @param string (optional) $identity
48
*/
49
public function __construct( $identity = null ) {
50
$this->entity = $identity;
51
}
52
53
/**
54
* Inscribe quality
55
*
56
* @since 0.10.0
57
*
58
* @param string $attribute
59
* @param mixed $characteristic
60
* @return self
61
*/
62
public function describe( $attribute, $characteristic ) {
63
$this->scribe[ $attribute ] = $characteristic;
64
return $this;
65
}
66
67
/**
68
* Evoke maiden /ɪgˈzɪstəns/
69
*
70
* @since 0.10.0
71
*
72
* @param ArtisanInterface $artisan
73
* @return Composite
74
*/
75
public function compose( ArtisanInterface $artisan ) {
76
$this->orchestrate( $this->aspect, $artisan );
77
return $artisan
78
->create( $this->entity )
79
->actualize();
80
}
81
82
/**
83
* Accord
84
*
85
* @since 0.10.0
86
*
87
* @param string $quality
88
* @param string|array (optional) $attributes
89
* @return self
90
*/
91
public function with( $quality, $attributes = null ) {
92
$this->aspect[ $quality ] = $attributes;
93
return $this;
94
}
95
96
/**
97
* Amalgamate
98
*
99
* @since 0.10.0
100
* @access private
101
*
102
* @param array $aspect
103
* @param ArtisanInterface $artisan
104
*/
105
private function orchestrate( array $aspect, ArtisanInterface &$artisan ) {
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.