PluginProbe
Tableberg – Simple Gutenberg Table Block / 1.1.5
Tableberg – Simple Gutenberg Table Block v1.1.5
1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.5 1.0.4 1.0.3 1.0.2 1.0.1 trunk 0.0.2 0.2.1 0.3.2 0.3.3 0.4.1 0.5.0 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 All 42 releases
tableberg / renderer / Attrs / Corners.php

Corners.php in Tableberg – Simple Gutenberg Table Block 1.1.5, at renderer/Attrs/Corners.php

54 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Tableberg\Renderer\Attrs;
4
5 use function Tableberg\Renderer\getOrNull;
6
7 class Corners {
8 /** @var StringAttr */
9 public $topLeft;
10
11 /** @var StringAttr */
12 public $topRight;
13
14 /** @var StringAttr */
15 public $bottomRight;
16
17 /** @var StringAttr */
18 public $bottomLeft;
19
20 /**
21 * @param array|null $data
22 * @param array<string, string> $defaults
23 * @return self
24 */
25 public static function from_array($data, $defaults) {
26 $data = is_array($data) ? $data : [];
27
28 $instance = new self();
29 $defaultTopLeft = getOrNull($defaults['topLeft']);
30 $defaultTopRight = getOrNull($defaults['topRight']);
31 $defaultBottomRight = getOrNull($defaults['bottomRight']);
32 $defaultBottomLeft = getOrNull($defaults['bottomLeft']);
33
34 $instance->topLeft = new StringAttr(
35 getOrNull($data['topLeft']),
36 $defaultTopLeft
37 );
38 $instance->topRight = new StringAttr(
39 getOrNull($data['topRight']),
40 $defaultTopRight
41 );
42 $instance->bottomRight = new StringAttr(
43 getOrNull($data['bottomRight']),
44 $defaultBottomRight
45 );
46 $instance->bottomLeft = new StringAttr(
47 getOrNull($data['bottomLeft']),
48 $defaultBottomLeft
49 );
50
51 return $instance;
52 }
53 }
54