Skip to content

Commit

Permalink
Merge pull request #9 from nasyrov/facade
Browse files Browse the repository at this point in the history
Facade
  • Loading branch information
Evgenii Nasyrov authored Oct 15, 2017
2 parents 9271e5a + 0ef5f22 commit 3969a92
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Laravel package for interactions.

Make sure all dependencies have been installed before moving on:

* [PHP](http://php.net/manual/en/install.php) >= 5.6
* [PHP](http://php.net/manual/en/install.php) >= 7.0
* [Composer](https://getcomposer.org/download/)

## Install
Expand Down
4 changes: 2 additions & 2 deletions src/CallsInteractions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Nasyrov\Laravel\Interactions;

use Nasyrov\Laravel\Interactions\Contracts\Interactor;
use Nasyrov\Laravel\Interactions\Facades\Interactor;

trait CallsInteractions
{
Expand All @@ -16,6 +16,6 @@ trait CallsInteractions
*/
public function interact($interaction, array $parameters = [])
{
return app(Interactor::class)->interact($interaction, $parameters);
return Interactor::interact($interaction, $parameters);
}
}
24 changes: 24 additions & 0 deletions src/Facades/Interactor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Nasyrov\Laravel\Interactions\Facades;

use Illuminate\Support\Facades\Facade;
use Nasyrov\Laravel\Interactions\Contracts\Interactor as InteractorContract;

/**
* @method static InteractorContract interact($interaction, array $parameters = [])
*
* @see InteractorContract
*/
class Interactor extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return InteractorContract::class;
}
}
16 changes: 16 additions & 0 deletions tests/Integration/Facades/InteractorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Nasyrov\Laravel\Interactions\Tests\Integration\Facades;

use Nasyrov\Laravel\Interactions\Facades\Interactor as InteractorFacade;
use Nasyrov\Laravel\Interactions\Interactor;
use Nasyrov\Laravel\Interactions\Tests\Integration\TestCase;

class InteractorTest extends TestCase
{
/** @test */
public function it_provides_facade()
{
$this->assertInstanceOf(Interactor::class, InteractorFacade::getFacadeRoot());
}
}

0 comments on commit 3969a92

Please sign in to comment.