OpenGraph\Opengraph::getArrayCopy PHP Метод

getArrayCopy() публичный Метод

Get array
public getArrayCopy ( ) : Array
Результат Array
    public function getArrayCopy()
    {
        $graph = array();
        $metas = static::$storage->getArrayCopy();
        foreach ($metas as $i => $meta) {
            $property = $meta->getProperty();
            $content = $meta->getContent();
            switch ($property) {
                case self::OG_IMAGE:
                    $data = array($property . ':url' => $content);
                    for ($j = $i + 1; $j <= $i + 4; $j++) {
                        if (isset($metas[$j])) {
                            $next = $metas[$j];
                            if (!empty($next)) {
                                $nextProperty = $next->getProperty();
                                switch ($nextProperty) {
                                    case self::OG_IMAGE_SECURE_URL:
                                    case self::OG_IMAGE_HEIGHT:
                                    case self::OG_IMAGE_WIDTH:
                                    case self::OG_IMAGE_TYPE:
                                        if (!isset($data[$nextProperty])) {
                                            $data[$nextProperty] = $next->getContent();
                                            unset($metas[$j]);
                                        }
                                        break;
                                }
                            }
                        }
                    }
                    if (!isset($graph[$property])) {
                        $graph[$property] = array();
                    }
                    $graph[$property][] = $data;
                    unset($data);
                    break;
                case self::OG_VIDEO:
                    $data = array($property . ':url' => $content);
                    for ($j = $i + 1; $j <= $i + 4; $j++) {
                        if (isset($metas[$j])) {
                            $next = $metas[$j];
                            if (!empty($next)) {
                                $nextProperty = $next->getProperty();
                                switch ($nextProperty) {
                                    case self::OG_VIDEO_SECURE_URL:
                                    case self::OG_VIDEO_HEIGHT:
                                    case self::OG_VIDEO_WIDTH:
                                    case self::OG_VIDEO_TYPE:
                                        if (!isset($data[$nextProperty])) {
                                            $data[$nextProperty] = $next->getContent();
                                            unset($metas[$j]);
                                        }
                                        break;
                                }
                            }
                        }
                    }
                    if (!isset($graph[$property])) {
                        $graph[$property] = array();
                    }
                    $graph[$property][] = $data;
                    unset($data);
                    break;
                case self::OG_AUDIO:
                    $data = array($property . ':url' => $content);
                    for ($j = $i + 1; $j <= $i + 2; $j++) {
                        if (isset($metas[$j])) {
                            $next = $metas[$j];
                            if (!empty($next)) {
                                $nextProperty = $next->getProperty();
                                switch ($nextProperty) {
                                    case self::OG_AUDIO_SECURE_URL:
                                    case self::OG_AUDIO_TYPE:
                                        if (!isset($data[$nextProperty])) {
                                            $data[$nextProperty] = $next->getContent();
                                            unset($metas[$j]);
                                        }
                                        break;
                                }
                            }
                        }
                    }
                    if (!isset($graph[$property])) {
                        $graph[$property] = array();
                    }
                    $graph[$property][] = $data;
                    unset($data);
                    break;
                default:
                    $denyProperties = array(self::OG_AUDIO_SECURE_URL, self::OG_AUDIO_TYPE, self::OG_VIDEO_SECURE_URL, self::OG_VIDEO_HEIGHT, self::OG_VIDEO_WIDTH, self::OG_VIDEO_TYPE, self::OG_IMAGE_SECURE_URL, self::OG_IMAGE_HEIGHT, self::OG_IMAGE_WIDTH, self::OG_IMAGE_TYPE);
                    if (!in_array($property, $denyProperties)) {
                        $graph[$property] = $content;
                        unset($metas[$i]);
                    }
            }
        }
        unset($metas);
        return $graph;
    }