header('Accept')), 'application/activity+json'); }); // configure Intervention/Image $this->app->bind('Intervention\Image\ImageManager', function () { return new \Intervention\Image\ImageManager(['driver' => config('image.driver')]); }); // Bind the Codebird client // Codebird gets mocked in tests // @codeCoverageIgnoreStart $this->app->bind('Codebird\Codebird', function () { Codebird::setConsumerKey( env('TWITTER_CONSUMER_KEY'), env('TWITTER_CONSUMER_SECRET') ); $cb = Codebird::getInstance(); $cb->setToken( env('TWITTER_ACCESS_TOKEN'), env('TWITTER_ACCESS_TOKEN_SECRET') ); return $cb; }); // @codeCoverageIgnoreEnd /** * Paginate a standard Laravel Collection. * * @param int $perPage * @param int $total * @param int $page * @param string $pageName * @return array */ Collection::macro('paginate', function ($perPage, $total = null, $page = null, $pageName = 'page') { $page = $page ?: LengthAwarePaginator::resolveCurrentPage($pageName); return new LengthAwarePaginator( $this->forPage($page, $perPage), $total ?: $this->count(), $perPage, $page, [ 'path' => LengthAwarePaginator::resolveCurrentPath(), 'pageName' => $pageName, ] ); }); // Configure JWT builder $this->app->bind('Lcobucci\JWT\Configuration', function () { $key = InMemory::plainText('testing'); $config = Configuration::forSymmetricSigner(new Sha256(), $key); $config->setValidationConstraints(new SignedWith(new Sha256(), $key)); return $config; }); // Configure HtmlSanitizer $this->app->bind(HtmlSanitizer::class, function () { return new HtmlSanitizer( (new HtmlSanitizerConfig()) ->allowSafeElements() ->forceAttribute('a', 'rel', 'noopener nofollow') ); }); } /** * Register any application services. * * @return void */ public function register() { if ($this->app->environment('local', 'testing')) { $this->app->register(DuskServiceProvider::class); } } }