Skip to content

Commit

Permalink
Removed addEvent from the GeneratorInterface, should only be used int…
Browse files Browse the repository at this point in the history
…ernally.
  • Loading branch information
frankdejonge committed Nov 25, 2014
1 parent fe69665 commit 83363a6
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 10 deletions.
22 changes: 22 additions & 0 deletions spec/League/Event/Stub/DomainGeneratorSpec.php
@@ -0,0 +1,22 @@
<?php

namespace spec\League\Event\Stub;

use League\Event\EventInterface;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

class DomainGeneratorSpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType('League\Event\Stub\DomainGenerator');
$this->shouldHaveType('League\Event\GeneratorInterface');
}

public function it_should_record_an_event_internally(EventInterface $event)
{
$this->recordAnEvent($event);
$this->releaseEvents()->shouldReturn([$event]);
}
}
10 changes: 10 additions & 0 deletions src/Generator.php
Expand Up @@ -5,4 +5,14 @@
class Generator implements GeneratorInterface
{
use GeneratorTrait;

/**
* {@inheritdoc}
*/
public function addEvent(EventInterface $event)
{
$this->events[] = $event;

return $this;
}
}
9 changes: 0 additions & 9 deletions src/GeneratorInterface.php
Expand Up @@ -4,15 +4,6 @@

interface GeneratorInterface
{
/**
* Add an event.
*
* @param EventInterface $event
*
* @return $this
*/
public function addEvent(EventInterface $event);

/**
* Release all the added events.
*
Expand Down
2 changes: 1 addition & 1 deletion src/GeneratorTrait.php
Expand Up @@ -18,7 +18,7 @@ trait GeneratorTrait
*
* @return $this
*/
public function addEvent(EventInterface $event)
protected function addEvent(EventInterface $event)
{
$this->events[] = $event;

Expand Down
17 changes: 17 additions & 0 deletions stubs/DomainGenerator.php
@@ -0,0 +1,17 @@
<?php

namespace League\Event\Stub;

use League\Event\EventInterface;
use League\Event\GeneratorInterface;
use League\Event\GeneratorTrait;

class DomainGenerator implements GeneratorInterface
{
use GeneratorTrait;

public function recordAnEvent(EventInterface $event)
{
$this->addEvent($event);
}
}

0 comments on commit 83363a6

Please sign in to comment.