Open Journal Systems  3.3.0
CssRule.php
1 <?php
2 /*
3  * citeproc-php
4  *
5  * @link http://github.com/seboettg/citeproc-php for the source repository
6  * @copyright Copyright (c) 2017 Sebastian Böttger.
7  * @license https://opensource.org/licenses/MIT
8  */
9 
11 
13 
19 class CssRule
20 {
21  const SELECTOR_TYPE_ID = "#";
22 
23  const SELECTOR_TYPE_CLASS = ".";
24 
28  private $selectorType;
29 
33  private $selector;
34 
38  private $directives;
39 
45  public function __construct($selector, $selectorType = self::SELECTOR_TYPE_CLASS)
46  {
47  $this->selector = $selector;
48  $this->selectorType = $selectorType;
49  $this->directives = new ArrayList();
50  }
51 
57  public function addDirective($property, $value)
58  {
59  $this->directives->append("$property: $value;");
60  }
61 
65  public function __toString()
66  {
67  $directives = "\t".implode("\n\t", $this->directives->toArray());
68  return $this->selectorType.$this->selector." {\n".$directives."\n}\n";
69  }
70 }
Seboettg\CiteProc\Styles\Css\CssRule\addDirective
addDirective($property, $value)
Definition: CssRule.php:66
Seboettg\CiteProc\Styles\Css\CssRule
Definition: CssRule.php:19
Seboettg\CiteProc\Styles\Css\CssRule\__toString
__toString()
Definition: CssRule.php:74
Seboettg\CiteProc\Styles\Css\CssRule\SELECTOR_TYPE_CLASS
const SELECTOR_TYPE_CLASS
Definition: CssRule.php:23
Seboettg\CiteProc\Styles\Css\CssRule\__construct
__construct($selector, $selectorType=self::SELECTOR_TYPE_CLASS)
Definition: CssRule.php:54
Seboettg\CiteProc\Styles\Css
Definition: CssRule.php:10
Seboettg\CiteProc\Styles\Css\CssRule\SELECTOR_TYPE_ID
const SELECTOR_TYPE_ID
Definition: CssRule.php:21
Seboettg\Collection\ArrayList
Definition: ArrayList.php:20