File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Astrotomic \OpenGraph ;
4+
5+ class TwitterProperty extends Property
6+ {
7+ /** @var string */
8+ protected $ prefix = 'twitter ' ;
9+
10+ public function __toString (): string
11+ {
12+ $ content = str_replace ('" ' , '" ' , $ this ->content );
13+
14+ return "<meta name= \"{$ this ->prefix }: {$ this ->property }\" content= \"{$ content }\"> " ;
15+ }
16+ }
Original file line number Diff line number Diff line change @@ -45,4 +45,14 @@ public function image(string $image, ?string $alt = null)
4545
4646 return $ this ;
4747 }
48+
49+ public function setProperty (string $ prefix , string $ property , string $ content )
50+ {
51+ $ this ->tags [$ prefix .': ' .$ property ] = TwitterProperty::make ($ prefix , $ property , $ content );
52+ }
53+
54+ public function addProperty (string $ prefix , string $ property , string $ content )
55+ {
56+ $ this ->tags [] = TwitterProperty::make ($ prefix , $ property , $ content );
57+ }
4858}
You can’t perform that action at this time.
0 commit comments