PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.1
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.1
2.4.0 2.4.1 2.3.8 2.3.7 2.3.6 2.3.5 2.3.4 2.3.3 2.3.2 2.3.1 2.2.0 2.1.21 2.1.20 2.1.19 2.1.18 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.2 All 57 releases
easy-invoice / vendor / sabberworm / php-css-parser / src / Value / URL.php

URL.php in Easy Invoice – Invoice Generator, PDF Quotes & Payments 2.4.1, at vendor/sabberworm/php-css-parser/src/Value/URL.php

102 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Sabberworm\CSS\Value;
4
5 use Sabberworm\CSS\OutputFormat;
6 use Sabberworm\CSS\Parsing\ParserState;
7 use Sabberworm\CSS\Parsing\SourceException;
8 use Sabberworm\CSS\Parsing\UnexpectedEOFException;
9 use Sabberworm\CSS\Parsing\UnexpectedTokenException;
10
11 /**
12 * This class represents URLs in CSS. `URL`s always output in `URL("")` notation.
13 */
14 class URL extends PrimitiveValue
15 {
16 /**
17 * @var CSSString
18 */
19 private $oURL;
20
21 /**
22 * @param int $iLineNo
23 */
24 public function __construct(CSSString $oURL, $iLineNo = 0)
25 {
26 parent::__construct($iLineNo);
27 $this->oURL = $oURL;
28 }
29
30 /**
31 * @return URL
32 *
33 * @throws SourceException
34 * @throws UnexpectedEOFException
35 * @throws UnexpectedTokenException
36 *
37 * @internal since V8.8.0
38 */
39 public static function parse(ParserState $oParserState)
40 {
41 $oAnchor = $oParserState->anchor();
42 $sIdentifier = '';
43 for ($i = 0; $i < 3; $i++) {
44 $sChar = $oParserState->parseCharacter(true);
45 if ($sChar === null) {
46 break;
47 }
48 $sIdentifier .= $sChar;
49 }
50 $bUseUrl = $oParserState->streql($sIdentifier, 'url');
51 if ($bUseUrl) {
52 $oParserState->consumeWhiteSpace();
53 $oParserState->consume('(');
54 } else {
55 $oAnchor->backtrack();
56 }
57 $oParserState->consumeWhiteSpace();
58 $oResult = new URL(CSSString::parse($oParserState), $oParserState->currentLine());
59 if ($bUseUrl) {
60 $oParserState->consumeWhiteSpace();
61 $oParserState->consume(')');
62 }
63 return $oResult;
64 }
65
66 /**
67 * @return void
68 */
69 public function setURL(CSSString $oURL)
70 {
71 $this->oURL = $oURL;
72 }
73
74 /**
75 * @return CSSString
76 */
77 public function getURL()
78 {
79 return $this->oURL;
80 }
81
82 /**
83 * @return string
84 *
85 * @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
86 */
87 public function __toString()
88 {
89 return $this->render(new OutputFormat());
90 }
91
92 /**
93 * @param OutputFormat|null $oOutputFormat
94 *
95 * @return string
96 */
97 public function render($oOutputFormat)
98 {
99 return "url({$this->oURL->render($oOutputFormat)})";
100 }
101 }
102