LaraComponents /
seo
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace LaraComponents\Seo\OpenGraph; |
||
| 4 | |||
| 5 | use LaraComponents\Seo\OpenGraph\Objects\TypeObject; |
||
| 6 | |||
| 7 | class OpenGraph |
||
| 8 | { |
||
| 9 | const DETERMINER_SUPPORTED = [ |
||
| 10 | 'a', 'an', 'auto', 'the', |
||
| 11 | ]; |
||
| 12 | |||
| 13 | const LOCALE_SUPPORTED = [ |
||
| 14 | 'af_ZA', 'ak_GH', 'am_ET', 'ar_AR', 'as_IN', 'ay_BO', 'az_AZ', 'be_BY', 'bg_BG', 'bn_IN', 'br_FR', |
||
| 15 | 'bs_BA', 'ca_ES', 'cb_IQ', 'ck_US', 'co_FR', 'cs_CZ', 'cx_PH', 'cy_GB', 'da_DK', 'de_DE', 'el_GR', |
||
| 16 | 'en_GB', 'en_IN', 'en_US', 'eo_EO', 'es_CO', 'es_ES', 'es_LA', 'et_EE', 'eu_ES', 'fa_IR', 'ff_NG', |
||
| 17 | 'fi_FI', 'fo_FO', 'fr_CA', 'fr_FR', 'fy_NL', 'ga_IE', 'gl_ES', 'gn_PY', 'gu_IN', 'gx_GR', 'ha_NG', |
||
| 18 | 'he_IL', 'hi_IN', 'hr_HR', 'hu_HU', 'hy_AM', 'id_ID', 'ig_NG', 'is_IS', 'it_IT', 'ja_JP', 'ja_KS', |
||
| 19 | 'jv_ID', 'ka_GE', 'kk_KZ', 'km_KH', 'kn_IN', 'ko_KR', 'ku_TR', 'la_VA', 'lg_UG', 'li_NL', 'ln_CD', |
||
| 20 | 'lo_LA', 'lt_LT', 'lv_LV', 'mg_MG', 'mk_MK', 'ml_IN', 'mn_MN', 'mr_IN', 'ms_MY', 'mt_MT', 'my_MM', |
||
| 21 | 'nb_NO', 'nd_ZW', 'ne_NP', 'nl_BE', 'nl_NL', 'nn_NO', 'ny_MW', 'or_IN', 'pa_IN', 'pl_PL', 'ps_AF', |
||
| 22 | 'pt_BR', 'pt_PT', 'qu_PE', 'rm_CH', 'ro_RO', 'ru_RU', 'rw_RW', 'sa_IN', 'sc_IT', 'se_NO', 'si_LK', |
||
| 23 | 'sk_SK', 'sl_SI', 'sn_ZW', 'so_SO', 'sq_AL', 'sr_RS', 'sv_SE', 'sw_KE', 'sy_SY', 'sz_PL', 'ta_IN', |
||
| 24 | 'te_IN', 'tg_TJ', 'th_TH', 'tk_TM', 'tl_PH', 'tr_TR', 'tt_RU', 'tz_MA', 'uk_UA', 'ur_PK', 'uz_UZ', |
||
| 25 | 'vi_VN', 'wo_SN', 'xh_ZA', 'yi_DE', 'yo_NG', 'zh_CN', 'zh_HK', 'zh_TW', 'zu_ZA', 'zz_TR', |
||
| 26 | ]; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @var string |
||
| 30 | */ |
||
| 31 | protected $type; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @var LaraComponents\Seo\OpenGraph\Objects\TypeObject |
||
| 35 | */ |
||
| 36 | protected $typeObject; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @var string |
||
| 40 | */ |
||
| 41 | protected $title; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @var string |
||
| 45 | */ |
||
| 46 | protected $siteName; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @var string |
||
| 50 | */ |
||
| 51 | protected $description; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @var string |
||
| 55 | */ |
||
| 56 | protected $url; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @var string |
||
| 60 | */ |
||
| 61 | protected $determiner; |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @var string |
||
| 65 | */ |
||
| 66 | protected $locale; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @var array |
||
| 70 | */ |
||
| 71 | protected $alternateLocales = []; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @var array |
||
| 75 | */ |
||
| 76 | protected $images = []; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @var array |
||
| 80 | */ |
||
| 81 | protected $audios = []; |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @var array |
||
| 85 | */ |
||
| 86 | protected $videos = []; |
||
| 87 | |||
| 88 | public function setType($type) |
||
| 89 | { |
||
| 90 | $this->type = $this->trim($type); |
||
| 91 | |||
| 92 | return $this; |
||
| 93 | } |
||
| 94 | |||
| 95 | public function getType() |
||
| 96 | { |
||
| 97 | return $this->type; |
||
| 98 | } |
||
| 99 | |||
| 100 | public function setTypeObject(TypeObject $typeObject) |
||
| 101 | { |
||
| 102 | $this->typeObject = $typeObject; |
||
|
0 ignored issues
–
show
|
|||
| 103 | } |
||
| 104 | |||
| 105 | public function getTypeObject() |
||
| 106 | { |
||
| 107 | return $this->typeObject; |
||
| 108 | } |
||
| 109 | |||
| 110 | public function setTitle($title) |
||
| 111 | { |
||
| 112 | $this->title = $this->trim($title); |
||
| 113 | |||
| 114 | return $this; |
||
| 115 | } |
||
| 116 | |||
| 117 | public function getTitle() |
||
| 118 | { |
||
| 119 | return $this->title; |
||
| 120 | } |
||
| 121 | |||
| 122 | public function setSiteName($siteName) |
||
| 123 | { |
||
| 124 | $this->siteName = $this->trim($siteName); |
||
| 125 | |||
| 126 | return $this; |
||
| 127 | } |
||
| 128 | |||
| 129 | public function getSiteName() |
||
| 130 | { |
||
| 131 | return $this->siteName; |
||
| 132 | } |
||
| 133 | |||
| 134 | public function setDescription($description) |
||
| 135 | { |
||
| 136 | $this->description = $this->trim($description); |
||
| 137 | |||
| 138 | return $this; |
||
| 139 | } |
||
| 140 | |||
| 141 | public function getDescription() |
||
| 142 | { |
||
| 143 | return $this->description; |
||
| 144 | } |
||
| 145 | |||
| 146 | public function setUrl($url) |
||
| 147 | { |
||
| 148 | $this->url = $this->trim($url); |
||
| 149 | |||
| 150 | return $this; |
||
| 151 | } |
||
| 152 | |||
| 153 | public function getUrl() |
||
| 154 | { |
||
| 155 | return $this->url; |
||
| 156 | } |
||
| 157 | |||
| 158 | public function setDeterminer($determiner) |
||
| 159 | { |
||
| 160 | if (in_array($determiner, OpenGraph::DETERMINER_SUPPORTED) || is_null($determiner)) { |
||
| 161 | $this->determiner = $determiner; |
||
| 162 | } |
||
| 163 | |||
| 164 | return $this; |
||
| 165 | } |
||
| 166 | |||
| 167 | public function getDeterminer() |
||
| 168 | { |
||
| 169 | return $this->determiner; |
||
| 170 | } |
||
| 171 | |||
| 172 | public function setLocale($locale) |
||
| 173 | { |
||
| 174 | if (in_array($locale, OpenGraph::LOCALE_SUPPORTED) || is_null($locale)) { |
||
| 175 | $this->locale = $locale; |
||
| 176 | } |
||
| 177 | |||
| 178 | return $this; |
||
| 179 | } |
||
| 180 | |||
| 181 | public function getLocale() |
||
| 182 | { |
||
| 183 | return $this->locale; |
||
| 184 | } |
||
| 185 | |||
| 186 | public function addAlternateLocale($locale) |
||
| 187 | { |
||
| 188 | if (in_array($locale, OpenGraph::LOCALE_SUPPORTED)) { |
||
| 189 | $this->alternateLocales[] = $locale; |
||
| 190 | } |
||
| 191 | |||
| 192 | return $this; |
||
| 193 | } |
||
| 194 | |||
| 195 | public function setAlternateLocales(array $locales) |
||
| 196 | { |
||
| 197 | $this->alternateLocales = []; |
||
| 198 | |||
| 199 | foreach ($locales as $locale) { |
||
| 200 | $this->addAlternateLocale($locale); |
||
| 201 | } |
||
| 202 | |||
| 203 | return $this; |
||
| 204 | } |
||
| 205 | |||
| 206 | public function getAlternateLocales() |
||
| 207 | { |
||
| 208 | return $this->alternateLocales; |
||
| 209 | } |
||
| 210 | |||
| 211 | public function addImage(Image $image) |
||
| 212 | { |
||
| 213 | $this->images[] = $image; |
||
| 214 | |||
| 215 | return $this; |
||
| 216 | } |
||
| 217 | |||
| 218 | public function setImages(array $images) |
||
| 219 | { |
||
| 220 | $this->images = []; |
||
| 221 | |||
| 222 | foreach ($images as $image) { |
||
| 223 | $this->addImage($image); |
||
| 224 | } |
||
| 225 | |||
| 226 | return $this; |
||
| 227 | } |
||
| 228 | |||
| 229 | public function getImages() |
||
| 230 | { |
||
| 231 | return $this->images; |
||
| 232 | } |
||
| 233 | |||
| 234 | public function addAudio(Audio $audio) |
||
| 235 | { |
||
| 236 | $this->audios[] = $audio; |
||
| 237 | |||
| 238 | return $this; |
||
| 239 | } |
||
| 240 | |||
| 241 | public function setAudios(array $audios) |
||
| 242 | { |
||
| 243 | $this->audios = []; |
||
| 244 | |||
| 245 | foreach ($audios as $audio) { |
||
| 246 | $this->addAudio($audio); |
||
| 247 | } |
||
| 248 | |||
| 249 | return $this; |
||
| 250 | } |
||
| 251 | |||
| 252 | public function getAudios() |
||
| 253 | { |
||
| 254 | return $this->audios; |
||
| 255 | } |
||
| 256 | |||
| 257 | public function addVideo(Video $video) |
||
| 258 | { |
||
| 259 | $this->videos[] = $video; |
||
| 260 | |||
| 261 | return $this; |
||
| 262 | } |
||
| 263 | |||
| 264 | public function setVideos(array $videos) |
||
| 265 | { |
||
| 266 | $this->videos = []; |
||
| 267 | |||
| 268 | foreach ($videos as $video) { |
||
| 269 | $this->addVideo($video); |
||
| 270 | } |
||
| 271 | |||
| 272 | return $this; |
||
| 273 | } |
||
| 274 | |||
| 275 | public function getVideos() |
||
| 276 | { |
||
| 277 | return $this->videos; |
||
| 278 | } |
||
| 279 | |||
| 280 | protected function trim($string) |
||
| 281 | { |
||
| 282 | $string = (is_string($string) && !empty(trim($string))) ? trim($string) : null; |
||
| 283 | |||
| 284 | return $string; |
||
| 285 | } |
||
| 286 | |||
| 287 | public function toArray() |
||
| 288 | { |
||
| 289 | $result = []; |
||
| 290 | |||
| 291 | $result['og:type'] = $this->getType(); |
||
| 292 | $result['og:title'] = $this->getTitle(); |
||
| 293 | $result['og:site_name'] = $this->getSiteName(); |
||
| 294 | $result['og:description'] = $this->getDescription(); |
||
| 295 | $result['og:url'] = $this->getUrl(); |
||
| 296 | $result['og:determiner'] = $this->getDeterminer(); |
||
| 297 | $result['og:locale'] = $this->getLocale(); |
||
| 298 | $result['og:locale:alternate'] = $this->getAlternateLocales(); |
||
| 299 | |||
| 300 | $result['og:image'] = []; |
||
| 301 | foreach ($this->getImages() as $image) { |
||
| 302 | $result['og:image'][] = $image->toArray(); |
||
| 303 | } |
||
| 304 | |||
| 305 | $result['og:audio'] = []; |
||
| 306 | foreach ($this->getAudios() as $audio) { |
||
| 307 | $result['og:audio'][] = $audio->toArray(); |
||
| 308 | } |
||
| 309 | |||
| 310 | $result['og:video'] = []; |
||
| 311 | foreach ($this->getVideos() as $video) { |
||
| 312 | $result['og:video'][] = $video->toArray(); |
||
| 313 | } |
||
| 314 | |||
| 315 | return array_filter($result); |
||
| 316 | } |
||
| 317 | } |
||
| 318 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..