* @see ParseUrl::getSiteinfo() for more information about scraping
* embeddable content
*/
- public static function getSiteinfoCached($url, $do_oembed = true): array
+ public static function getSiteinfoCached(string $url, bool $do_oembed = true): array
{
if (empty($url)) {
return [
* </body>
* @endverbatim
*/
- public static function getSiteinfo($url, $do_oembed = true, $count = 1)
+ public static function getSiteinfo(string $url, bool $do_oembed = true, int $count = 1)
{
if (empty($url)) {
return [
* @param string $string Tags
* @return array with formatted Hashtags
*/
- public static function convertTagsToArray($string)
+ public static function convertTagsToArray(string $string): array
{
$arr_tags = str_getcsv($string);
if (count($arr_tags)) {
// add the # sign to every tag
- array_walk($arr_tags, ["self", "arrAddHashes"]);
+ array_walk($arr_tags, ['self', 'arrAddHashes']);
return $arr_tags;
}
+ return [];
}
/**
* @param int $k Counter for internal use
* @return void
*/
- private static function arrAddHashes(&$tag, $k)
+ private static function arrAddHashes(string &$tag, int $k)
{
- $tag = "#" . $tag;
+ $tag = '#' . $tag;
}
/**
*
* @return string The url with a scheme
*/
- private static function completeUrl($url, $scheme)
+ private static function completeUrl(string $url, string $scheme): string
{
$urlarr = parse_url($url);
// If the url does allready have an scheme
// we can stop the process here
- if (isset($urlarr["scheme"])) {
- return($url);
+ if (isset($urlarr['scheme'])) {
+ return $url;
}
$schemearr = parse_url($scheme);
- $complete = $schemearr["scheme"]."://".$schemearr["host"];
+ $complete = $schemearr['scheme'] . '://' . $schemearr['host'];
- if (!empty($schemearr["port"])) {
- $complete .= ":".$schemearr["port"];
+ if (!empty($schemearr['port'])) {
+ $complete .= ':' . $schemearr['port'];
}
- if (!empty($urlarr["path"])) {
- if (strpos($urlarr["path"], "/") !== 0) {
- $complete .= "/";
+ if (!empty($urlarr['path'])) {
+ if (strpos($urlarr['path'], '/') !== 0) {
+ $complete .= '/';
}
- $complete .= $urlarr["path"];
+ $complete .= $urlarr['path'];
}
- if (!empty($urlarr["query"])) {
- $complete .= "?".$urlarr["query"];
+ if (!empty($urlarr['query'])) {
+ $complete .= '?' . $urlarr['query'];
}
- if (!empty($urlarr["fragment"])) {
- $complete .= "#".$urlarr["fragment"];
+ if (!empty($urlarr['fragment'])) {
+ $complete .= '#' . $urlarr['fragment'];
}
- return($complete);
+ return $complete;
}
/**
* @param array $jsonld
* @return array siteinfo
*/
- private static function parseParts(array $siteinfo, array $jsonld)
+ private static function parseParts(array $siteinfo, array $jsonld): array
{
if (!empty($jsonld['@graph']) && is_array($jsonld['@graph'])) {
foreach ($jsonld['@graph'] as $part) {
* @param array $jsonld
* @return array siteinfo
*/
- private static function parseJsonLd(array $siteinfo, array $jsonld)
+ private static function parseJsonLd(array $siteinfo, array $jsonld): array
{
$type = JsonLD::fetchElement($jsonld, '@type');
if (empty($type)) {
* @param array $jsonld
* @return array siteinfo
*/
- private static function parseJsonLdAuthor(array $siteinfo, array $jsonld)
+ private static function parseJsonLdAuthor(array $siteinfo, array $jsonld): array
{
$jsonldinfo = [];
* @param array $jsonld
* @return array siteinfo
*/
- private static function parseJsonLdArticle(array $siteinfo, array $jsonld)
+ private static function parseJsonLdArticle(array $siteinfo, array $jsonld): array
{
$jsonldinfo = [];
* @param array $jsonld
* @return array siteinfo
*/
- private static function parseJsonLdWebPage(array $siteinfo, array $jsonld)
+ private static function parseJsonLdWebPage(array $siteinfo, array $jsonld): array
{
$jsonldinfo = [];
* @param array $jsonld
* @return array siteinfo
*/
- private static function parseJsonLdWebSite(array $siteinfo, array $jsonld)
+ private static function parseJsonLdWebSite(array $siteinfo, array $jsonld): array
{
$jsonldinfo = [];
* @param array $jsonld
* @return array siteinfo
*/
- private static function parseJsonLdWebOrganization(array $siteinfo, array $jsonld)
+ private static function parseJsonLdWebOrganization(array $siteinfo, array $jsonld): array
{
$jsonldinfo = [];
* @param array $jsonld
* @return array siteinfo
*/
- private static function parseJsonLdWebPerson(array $siteinfo, array $jsonld)
+ private static function parseJsonLdWebPerson(array $siteinfo, array $jsonld): array
{
$jsonldinfo = [];
* @param array $jsonld
* @return array siteinfo
*/
- private static function parseJsonLdMediaObject(array $siteinfo, array $jsonld, string $name)
+ private static function parseJsonLdMediaObject(array $siteinfo, array $jsonld, string $name): array
{
$media = [];