<?php

namespace App\Traits;

trait ExtractOgImageID
{
    public function getID($og_image): int | null
    {
        if (is_array($og_image) && array_key_exists("media_id", $og_image)) {
            return $og_image['media_id'];
        } elseif (is_object($og_image) && isset($og_image->media_id)) {
            return $og_image->media_id;
        }

        return $og_image;
    }
}
