<?php

namespace Joe1992w\LaravelMediaEmbed\Services;

use MediaEmbed\MediaEmbed;

class LaravelMediaEmbed
{
  public function parse($url = null, $whitelist = [], $params = [], $attributes = []) {

    $MediaEmbed = new MediaEmbed();

    $MediaObject = $MediaEmbed->parseUrl($url);

    if ($MediaObject)
    {

      if(is_array($params))
      {
        $MediaObject->setParam($params);
      }

      if(is_array($params))
      {
        $MediaObject->setAttribute($attributes);
      }


      if (!empty($whitelist))
      {

        if(!in_array($MediaObject->name(), $whitelist))
        {

          return false;

        }

      }

      return $MediaObject->getEmbedCode();

    }

    return false;

  }

}

<?php

namespace Joe1992w\LaravelMediaEmbed\Services;

use MediaEmbed\MediaEmbed;

class LaravelMediaEmbed
{
  public function parse($url = null, $whitelist = [], $params = [], $attributes = []) {

    $MediaEmbed = new MediaEmbed();

    $MediaObject = $MediaEmbed->parseUrl($url);

    if ($MediaObject)
    {

      if(is_array($params))
      {
        $MediaObject->setParam($params);
      }

      if(is_array($params))
      {
        $MediaObject->setAttribute($attributes);
      }


      if (!empty($whitelist))
      {

        if(!in_array($MediaObject->name(), $whitelist))
        {

          return false;

        }

      }

      return $MediaObject;

    }

    return false;

  }

}

Return MediaObject class instead of string
Return MediaObject class instead of string

__toString method on object returns embed URL as before so no usage
changes required
