<?php

namespace Dipper\Sms;

use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Container\Container;
use Laravel\Lumen\Application as LumenApplication;

class SmsServiceProvider extends ServiceProvider
{
    protected $defer = true;

    public function register()
    {
        $this->app->singleton('sms', function (Container $app) {
            return new Sms($app['config']['sms']);
        });
    }

    public function boot()
    {
        $source = realpath(__DIR__.'/../config/sms.php');

        if ($this->app instanceof LumenApplication) {
            $this->app->configure('sms');
        }

        $this->mergeConfigFrom($source, 'sms');
    }
}
