<?php

namespace Lc\SovBundle\Component;

class MetaComponent
{

    public function getMetaTitle($entity)
    {
        if($entity) {
            if(method_exists($entity, 'getMetaTitle')) {
                return $entity->getMetaTitle() ;
            }
            elseif(method_exists($entity, 'getTitle')) {
                return $entity->getTitle() ;
            }
        }

        return '' ;
    }

    public function getMetaDescription($entity)
    {
        if($entity) {
            if(method_exists($entity, 'getMetaDescription')) {
                return $entity->getMetaDescription() ;
            }
            elseif(method_exists($entity, 'getDescription')) {
                return $entity->getDescription() ;
            }
        }

        return '' ;
    }

    public function getOpenGraphTitle($entity)
    {
        if($entity) {
            if(method_exists($entity, 'getOpenGraphTitle')) {
                return $entity->getOpenGraphTitle() ;
            }
            elseif(method_exists($entity, 'getTitle')) {
                return $entity->getTitle() ;
            }
        }

        return '' ;
    }

    public function getOpenGraphDescription($entity)
    {
        if($entity) {
            if(method_exists($entity, 'getOpenGraphDescription')) {
                return $entity->getOpenGraphDescription() ;
            }
            elseif(method_exists($entity, 'getDescription')) {
                return $entity->getDescription() ;
            }
        }

        return '' ;
    }

    public function getOpenGraphImage($entity)
    {
        if($entity) {
            if(method_exists($entity, 'getOpenGraphImage')) {
                return $entity->getOpenGraphImage() ;
            }
            elseif(method_exists($entity, 'getImage')) {
                return $entity->getImage() ;
            }
        }

        return '' ;
    }

}
