File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -14,17 +14,22 @@ trait Properties
14
14
/**
15
15
* @return static $properties [description]
16
16
*/
17
- public function props (string ...$ properties )
17
+ public function props (string ...$ properties ): static
18
18
{
19
19
$ this ->properties = $ properties ;
20
20
return $ this ;
21
21
}
22
22
23
+ public function prop (string $ prop ): static
24
+ {
25
+ $ this ->properties [] = $ prop ;
26
+ return $ this ;
27
+ }
28
+
23
29
protected function propertiesString (): string
24
30
{
25
31
if (count ($ this ->properties ()) === 0 ) {
26
32
return '' ;
27
-
28
33
}
29
34
30
35
$ b = [];
Original file line number Diff line number Diff line change @@ -39,10 +39,20 @@ public function element_can_omit_end_tag(): void
39
39
*/
40
40
public function element_can_have_properties (): void
41
41
{
42
+ // basic
42
43
$ this ->assertEquals (
43
44
Element::create ('root ' )->props ('id 6 ' , 'property hello ' )->build (),
44
45
'<root id="6" property="hello"></root> '
45
46
);
47
+
48
+ // add
49
+ $ this ->assertEquals (
50
+ Element::create ('root ' )
51
+ ->props ('id 6 ' , 'property hello ' )
52
+ ->prop ('class something ' )
53
+ ->build (),
54
+ '<root id="6" property="hello" class="something"></root> '
55
+ );
46
56
}
47
57
48
58
/**
You can’t perform that action at this time.
0 commit comments