Skip to content

Commit

Permalink
Merge pull request #5 from symfony-bundles/2.0
Browse files Browse the repository at this point in the history
[Refactoring] Updated Code Style
  • Loading branch information
khaperets authored Oct 17, 2017
2 parents 39e43be + 3f81cf0 commit 1e35bf4
Show file tree
Hide file tree
Showing 34 changed files with 46 additions and 121 deletions.
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ build:
tests:
override:
-
command: phpunit --coverage-clover ./clover.xml
command: ./vendor/bin/phpunit --coverage-clover ./clover.xml
coverage:
file: clover.xml
format: clover
41 changes: 15 additions & 26 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
language: php

sudo: false

cache:
directories:
- $HOME/.composer/cache

php:
- 5.6
- 7.0
- hhvm
- nightly
- 7.1
- 7.2

env:
- SYMFONY_VERSION=2.7.*
- SYMFONY_VERSION=2.8.*
- SYMFONY_VERSION=3.0.*
- SYMFONY_VERSION=3.1.*
- SYMFONY_VERSION=3.2.*
- SYMFONY_VERSION=3.3.*

cache:
directories:
- $HOME/.composer/cache

services:
- redis-server
Expand All @@ -26,22 +33,4 @@ install:
- composer install

script:
- phpunit

matrix:
fast_finish: true
include:
- php: 5.6
env: SYMFONY_VERSION=2.7.*
- php: 5.6
env: SYMFONY_VERSION=2.8.*
- php: 5.6
env: SYMFONY_VERSION=3.0.*
- php: 7.0
env: SYMFONY_VERSION=3.0.*
allow_failures:
- php: hhvm
- php: nightly

notifications:
email: false
- ./vendor/bin/phpunit
4 changes: 1 addition & 3 deletions Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

abstract class Command extends ContainerAwareCommand
{

/**
* @var QueueProcess
*/
Expand All @@ -23,12 +22,11 @@ protected function initialize(InputInterface $input, OutputInterface $output)

$path = $this->getContainer()->getParameter('sb_event_queue.storage_path');

$this->process = new QueueProcess;
$this->process = new QueueProcess();
$this->process->setPath($path);

if ($input->hasOption('name')) {
$this->process->setQueueName($input->getOption('name'));
}
}

}
6 changes: 2 additions & 4 deletions Command/Daemon/StartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

namespace SymfonyBundles\EventQueueBundle\Command\Daemon;

use SymfonyBundles\EventQueueBundle\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use SymfonyBundles\EventQueueBundle\Command\Command;
use Symfony\Component\Console\Output\OutputInterface;

class StartCommand extends Command
{

/**
* {@inheritdoc}
*/
Expand All @@ -37,7 +36,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->process->save();

while ($this->process->has()) {
$iterations--;
--$iterations;

$dispatcher->run($dispatcherInput, $output);

Expand All @@ -48,5 +47,4 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}
}

}
4 changes: 1 addition & 3 deletions Command/Daemon/StopCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

namespace SymfonyBundles\EventQueueBundle\Command\Daemon;

use SymfonyBundles\EventQueueBundle\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use SymfonyBundles\EventQueueBundle\Command\Command;
use Symfony\Component\Console\Output\OutputInterface;

class StopCommand extends Command
{

/**
* {@inheritdoc}
*/
Expand All @@ -28,5 +27,4 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$this->process->kill();
}

}
2 changes: 0 additions & 2 deletions Command/DispatchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

class DispatchCommand extends Command
{

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -36,5 +35,4 @@ protected function execute(InputInterface $input, OutputInterface $output)
$dispatcher->dispatch();
}
}

}
2 changes: 0 additions & 2 deletions Command/QueueProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

class QueueProcess
{

/**
* @var string
*/
Expand Down Expand Up @@ -74,5 +73,4 @@ public function kill()
{
return $this->delete();
}

}
2 changes: 0 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

class Configuration implements ConfigurationInterface
{

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -69,5 +68,4 @@ private function addClassSection(ArrayNodeDefinition $node)
->end()
->end();
}

}
2 changes: 0 additions & 2 deletions DependencyInjection/EventQueueExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

class EventQueueExtension extends ConfigurableExtension
{

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -39,5 +38,4 @@ public function getAlias()
{
return 'sb_event_queue';
}

}
2 changes: 0 additions & 2 deletions Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

abstract class Event extends BaseEvent implements EventInterface
{

/**
* @var string
*/
Expand All @@ -19,5 +18,4 @@ public function getName()
{
return static::NAME;
}

}
1 change: 0 additions & 1 deletion EventInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

interface EventInterface
{

/**
* Returns whether further event listeners should be triggered.
*
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 Symfony Bundles (Dmitry Khaperets)
Copyright (c) 2016-2017 Symfony Bundles (Dmitry Khaperets)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ Defaults configuration:

``` yml
sb_event_queue:
service_name: "event_queue"
default_name: "event:default"
storage_path: "%kernel.cache_dir%/event-queue-daemon.%s.pid"
service_name: 'event_queue'
default_name: 'event:default'
storage_path: '%kernel.cache_dir%/event-queue-daemon.%s.pid'
```
* Configure the redis client in your config.yml. Read more about [RedisBundle configuration][redis-bundle-link].
Expand All @@ -68,7 +68,6 @@ use SymfonyBundles\EventQueueBundle\Event;

class MyEvent extends Event
{

const NAME = 'event.example';

private $time;
Expand All @@ -89,7 +88,6 @@ class MyEvent extends Event
{
return $this->message;
}

}
```

Expand All @@ -103,15 +101,13 @@ use AppBundle\Event\MyEvent;

class MyListener
{

public function onEventExample(MyEvent $event)
{
$event->getTime();
$event->getMessage();

// and we are doing something...
}

}
```

Expand Down
2 changes: 0 additions & 2 deletions Service/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

class Dispatcher extends Queue implements DispatcherInterface
{

/**
* @var EventDispatcherInterface
*/
Expand Down Expand Up @@ -55,5 +54,4 @@ public function dispatch()

return $this->dispatcher->dispatch($event->getName(), $event);
}

}
3 changes: 0 additions & 3 deletions Service/DispatcherInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

interface DispatcherInterface
{

/**
* Adds an event listener to the queue.
*
Expand All @@ -13,8 +12,6 @@ interface DispatcherInterface
*
* @throws Exception\InvalidEventNameException
* @throws Exception\InvalidEventParentClassException
*
* @return void
*/
public function on($class, ...$args);

Expand Down
2 changes: 0 additions & 2 deletions Service/Exception/EventInterfaceImplementationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

class EventInterfaceImplementationException extends \InvalidArgumentException
{

/**
* {@inheritdoc}
*/
Expand All @@ -16,5 +15,4 @@ public function __construct($message, $code = 0, \Exception $previous = null)

parent::__construct($message, $code, $previous);
}

}
2 changes: 0 additions & 2 deletions Service/Exception/InvalidEventNameException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

class InvalidEventNameException extends \InvalidArgumentException
{

/**
* {@inheritdoc}
*/
Expand All @@ -14,5 +13,4 @@ public function __construct($message, $code = 0, \Exception $previous = null)

parent::__construct($message, $code, $previous);
}

}
4 changes: 1 addition & 3 deletions SymfonyBundlesEventQueueBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

class SymfonyBundlesEventQueueBundle extends Bundle implements BundleDependencyInterface
{

use BundleDependency;

/**
Expand All @@ -25,8 +24,7 @@ public function getContainerExtension()
public function getBundleDependencies()
{
return [
\SymfonyBundles\QueueBundle\SymfonyBundlesQueueBundle::class
\SymfonyBundles\QueueBundle\SymfonyBundlesQueueBundle::class,
];
}

}
16 changes: 7 additions & 9 deletions Tests/Command/Daemon/StartCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@

class StartCommandTest extends ConsoleTestCase
{

public function testConfigure()
{
$command = new Command\Daemon\StartCommand;
$command = new Command\Daemon\StartCommand();

$this->assertEquals('event:queue:daemon:start', $command->getName());
}
Expand All @@ -24,21 +23,20 @@ public function testExecute()

$this->assertSame(3, $this->dispatcher->count());

$this->createTester(new Command\DispatchCommand, 'event:queue:dispatch');
$this->createTester(new Command\DispatchCommand(), 'event:queue:dispatch');

$start = $this->createTester(new Command\Daemon\StartCommand, 'event:queue:daemon:start');
$start = $this->createTester(new Command\Daemon\StartCommand(), 'event:queue:daemon:start');

$start->execute([
'--name' => 'unit-test',
'--delay' => 0,
'--iterations' => 1
'--name' => 'unit-test',
'--delay' => 0,
'--iterations' => 1,
]);

$this->assertSame(0, $this->dispatcher->count());

$stop = $this->createTester(new Command\Daemon\StopCommand, 'event:queue:daemon:stop');
$stop = $this->createTester(new Command\Daemon\StopCommand(), 'event:queue:daemon:stop');

$stop->execute(['--name' => 'unit-test']);
}

}
Loading

0 comments on commit 1e35bf4

Please sign in to comment.