55
66namespace Hammerstone \Torchlight ;
77
8- use Illuminate \Support \Facades \Cache ;
98use Illuminate \Support \Str ;
109
1110class Block
1211{
12+ /**
13+ * The language of the code that is being highlighted.
14+ *
15+ * @var string
16+ */
1317 public $ language ;
1418
19+ /**
20+ * The theme of the code.
21+ *
22+ * @var string
23+ */
1524 public $ theme ;
1625
26+ /**
27+ * The code itself.
28+ *
29+ * @var string
30+ */
1731 public $ code ;
1832
19- public $ highlighted ;
20-
33+ /**
34+ * The highlighted code, wrapped in pre+code tags.
35+ *
36+ * @var string
37+ */
2138 public $ wrapped ;
2239
40+ /**
41+ * The highlighted code, not wrapped.
42+ *
43+ * @var string
44+ */
45+ public $ highlighted ;
46+
47+ /**
48+ * Classes that should be applied to the code tag.
49+ *
50+ * @var string
51+ */
2352 public $ classes ;
2453
54+ /**
55+ * Styles that should be applied to the code tag.
56+ *
57+ * @var string
58+ */
2559 public $ styles ;
2660
27- public $ cacheBust = 0 ;
28-
61+ /**
62+ * The unique ID for the block.
63+ *
64+ * @var string
65+ */
2966 protected $ id ;
3067
3168 /**
@@ -45,9 +82,6 @@ public function __construct($id = null)
4582 // Generate a unique UUID.
4683 $ this ->id = $ id ?? (string )Str::uuid ();
4784
48- // An easy way to bust all caches.
49- $ this ->cacheBust = config ('torchlight.bust ' , 0 );
50-
5185 // Set a default theme.
5286 $ this ->theme = config ('torchlight.theme ' );
5387 }
@@ -65,10 +99,11 @@ public function id()
6599 */
66100 public function hash ()
67101 {
68- return md5 ($ this ->language . $ this ->theme . $ this ->code . $ this -> cacheBust );
102+ return md5 ($ this ->language . $ this ->theme . $ this ->code . config ( ' torchlight.bust ' ) );
69103 }
70104
71105 /**
106+ * @param string $extra
72107 * @return string
73108 */
74109 public function placeholder ($ extra = '' )
@@ -84,7 +119,7 @@ public function placeholder($extra = '')
84119 * @param $language
85120 * @return $this
86121 */
87- public function setLanguage ($ language )
122+ public function language ($ language )
88123 {
89124 $ this ->language = $ language ;
90125
@@ -95,7 +130,7 @@ public function setLanguage($language)
95130 * @param $theme
96131 * @return $this
97132 */
98- public function setTheme ($ theme )
133+ public function theme ($ theme )
99134 {
100135 if ($ theme ) {
101136 $ this ->theme = $ theme ;
@@ -108,29 +143,18 @@ public function setTheme($theme)
108143 * @param $code
109144 * @return $this
110145 */
111- public function setCode ($ code )
146+ public function code ($ code )
112147 {
113148 $ this ->code = $ this ->clean ($ code );
114149
115150 return $ this ;
116151 }
117152
118- /**
119- * @param $number
120- * @return $this
121- */
122- public function setCacheBust ($ number )
123- {
124- $ this ->cacheBust = $ number ;
125-
126- return $ this ;
127- }
128-
129153 /**
130154 * @param $wrapped
131155 * @return $this
132156 */
133- public function setWrapped ($ wrapped )
157+ public function wrapped ($ wrapped )
134158 {
135159 $ this ->wrapped = $ wrapped ;
136160
@@ -148,7 +172,6 @@ public function toRequestParams()
148172 'language ' => $ this ->language ,
149173 'theme ' => $ this ->theme ,
150174 'code ' => $ this ->code ,
151- 'bust ' => $ this ->cacheBust
152175 ];
153176 }
154177
0 commit comments