PluginProbe
The Innovative Form Builder – IvyForms / 1.4
The Innovative Form Builder – IvyForms v1.4
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Services / Form / Style / CssBuilder.php

CssBuilder.php in The Innovative Form Builder – IvyForms 1.4, at backend/src/Services/Form/Style/CssBuilder.php

69 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 /**
4 * @copyright © Melograno Venture Studio. All rights reserved.
5 * @licence See LICENCE.md for license details.
6 */
7
8 namespace IvyForms\Services\Form\Style;
9
10 // phpcs:disable PSR1.Files.SideEffects
11 if (!defined('ABSPATH')) {
12 exit; // Exit if accessed directly
13 }
14
15 /**
16 * Class CssBuilder
17 *
18 * Helper for building CSS rules
19 *
20 * @package IvyForms\Services\Form\StyleHelpers
21 */
22 class CssBuilder
23 {
24 /**
25 * @var string[]
26 */
27 private array $css = [];
28
29 /**
30 * Add a CSS rule block
31 *
32 * @param string|string[] $selectors
33 * @param string[] $properties
34 * @return void
35 */
36 public function addRule($selectors, array $properties): void
37 {
38 if (empty($properties)) {
39 return;
40 }
41
42 $selectorString = is_array($selectors) ? implode(',', $selectors) : $selectors;
43 $this->css[] = $selectorString . ' {';
44 $this->css = array_merge($this->css, $properties);
45 $this->css[] = '}';
46 }
47
48 /**
49 * Add raw CSS lines
50 *
51 * @param string[] $lines
52 * @return void
53 */
54 public function addLines(array $lines): void
55 {
56 $this->css = array_merge($this->css, $lines);
57 }
58
59 /**
60 * Get the generated CSS
61 *
62 * @return string
63 */
64 public function build(): string
65 {
66 return implode("\n", $this->css);
67 }
68 }
69