@@ -49,7 +49,7 @@ |
||
| 49 | 49 | |
| 50 | 50 | // @TODO: Add existing bundle validation |
| 51 | 51 | $question->setValidator(['Sensio\Bundle\GeneratorBundle\Command\Validators', 'validateBundleName']); |
| 52 | - $question->setNormalizer(function ($value) { |
|
| 52 | + $question->setNormalizer(function($value) { |
|
| 53 | 53 | return $value ? trim($value) : ''; |
| 54 | 54 | }); |
| 55 | 55 | $question->setMaxAttempts(2); |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | public function markAsRead() |
| 36 | 36 | { |
| 37 | 37 | // @TODO: sort it. |
| 38 | - $this->entities->forAll(function ($notification) { |
|
| 38 | + $this->entities->forAll(function($notification) { |
|
| 39 | 39 | $notification->markAsRead(); |
| 40 | 40 | }); |
| 41 | 41 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | // @TODO: Add existing bundle validation |
| 63 | 63 | $question->setValidator(['Sensio\Bundle\GeneratorBundle\Command\Validators', 'validateBundleName']); |
| 64 | 64 | $question->setNormalizer( |
| 65 | - function ($value) { |
|
| 65 | + function($value) { |
|
| 66 | 66 | return $value ? trim($value) : ''; |
| 67 | 67 | } |
| 68 | 68 | ); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | $input->getOption('notification_name') |
| 86 | 86 | ); |
| 87 | 87 | $question->setValidator( |
| 88 | - function ($answer) { |
|
| 88 | + function($answer) { |
|
| 89 | 89 | // Should only contain letters. |
| 90 | 90 | $valid = preg_match('/^[a-zA-Z]+$/', $answer); |
| 91 | 91 | if (!$valid) { |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | ); |
| 100 | 100 | $question->setNormalizer( |
| 101 | - function ($value) { |
|
| 101 | + function($value) { |
|
| 102 | 102 | return $value ? trim($value) : ''; |
| 103 | 103 | } |
| 104 | 104 | ); |
@@ -164,19 +164,19 @@ discard block |
||
| 164 | 164 | ), 'yes' |
| 165 | 165 | ); |
| 166 | 166 | $question->setNormalizer( |
| 167 | - function ($value) { |
|
| 167 | + function($value) { |
|
| 168 | 168 | return $value[0] == 'y' ? 'y' : 'n'; |
| 169 | 169 | } |
| 170 | 170 | ); |
| 171 | 171 | |
| 172 | 172 | $question->setValidator( |
| 173 | - function ($answer) { |
|
| 173 | + function($answer) { |
|
| 174 | 174 | // Should only contain letters. |
| 175 | 175 | $allowed = [ |
| 176 | 176 | 'y', |
| 177 | 177 | 'n', |
| 178 | 178 | ]; |
| 179 | - $valid = in_array($answer, $allowed); |
|
| 179 | + $valid = in_array($answer, $allowed); |
|
| 180 | 180 | if (!$valid) { |
| 181 | 181 | throw new \RuntimeException( |
| 182 | 182 | 'Only allowed value are ' . implode(', ', $allowed) |
@@ -155,6 +155,10 @@ discard block |
||
| 155 | 155 | $questionHelper->writeGeneratorSummary($output, []); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | + /** |
|
| 159 | + * @param \Sensio\Bundle\GeneratorBundle\Command\Helper\QuestionHelper $questionHelper |
|
| 160 | + * @param InputInterface $input |
|
| 161 | + */ |
|
| 158 | 162 | protected function createYesNoQuestion($questionHelper, $input, $channel) |
| 159 | 163 | { |
| 160 | 164 | $question = new Question( |
@@ -164,12 +168,20 @@ discard block |
||
| 164 | 168 | ), 'yes' |
| 165 | 169 | ); |
| 166 | 170 | $question->setNormalizer( |
| 171 | + |
|
| 172 | + /** |
|
| 173 | + * @param \Sensio\Bundle\GeneratorBundle\Command\Helper\QuestionHelper $value |
|
| 174 | + */ |
|
| 167 | 175 | function ($value) { |
| 168 | 176 | return $value[0] == 'y' ? 'y' : 'n'; |
| 169 | 177 | } |
| 170 | 178 | ); |
| 171 | 179 | |
| 172 | 180 | $question->setValidator( |
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * @param \Sensio\Bundle\GeneratorBundle\Command\Helper\QuestionHelper $answer |
|
| 184 | + */ |
|
| 173 | 185 | function ($answer) { |
| 174 | 186 | // Should only contain letters. |
| 175 | 187 | $allowed = [ |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace IrishDan\NotificationBundle\DependencyInjection; |
| 4 | 4 | |
| 5 | -use IrishDan\NotificationBundle\DependencyInjection\Factory\Broadcaster\SlackBroadcasterFactory; |
|
| 6 | 5 | use Symfony\Component\DependencyInjection\Definition; |
| 7 | 6 | use Symfony\Component\DependencyInjection\Reference; |
| 8 | 7 | use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
@@ -86,6 +86,9 @@ |
||
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | + /** |
|
| 90 | + * @param ContainerBuilder $container |
|
| 91 | + */ |
|
| 89 | 92 | private function createBroadcaster($name, $broadcaster, $container) |
| 90 | 93 | { |
| 91 | 94 | // @TODO: |
@@ -72,8 +72,7 @@ |
||
| 72 | 72 | try { |
| 73 | 73 | if (!empty($this->dispatchers[$dispatcherKey])) { |
| 74 | 74 | $this->dispatchers[$dispatcherKey]->dispatch($message); |
| 75 | - } |
|
| 76 | - else { |
|
| 75 | + } else { |
|
| 77 | 76 | throw new MessageDispatchException( |
| 78 | 77 | sprintf('No dispatcher available with key "%s"', $dispatcherKey) |
| 79 | 78 | ); |
@@ -21,8 +21,8 @@ |
||
| 21 | 21 | $this->notification = $this->getNotificationWithUser(); |
| 22 | 22 | |
| 23 | 23 | $this->eventDispatcher = $this->getMockBuilder(EventDispatcherInterface::class) |
| 24 | - ->disableOriginalConstructor() |
|
| 25 | - ->getMock(); |
|
| 24 | + ->disableOriginalConstructor() |
|
| 25 | + ->getMock(); |
|
| 26 | 26 | |
| 27 | 27 | $this->eventChannel = new EventChannel($this->eventDispatcher); |
| 28 | 28 | } |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | 'cluster' => $this->config['cluster'], |
| 34 | 34 | 'encrypted' => $this->config['encrypted'], |
| 35 | 35 | ]; |
| 36 | - $pusher = new \Pusher( |
|
| 36 | + $pusher = new \Pusher( |
|
| 37 | 37 | $this->config['auth_key'], |
| 38 | 38 | $this->config['secret'], |
| 39 | 39 | $this->config['app_id'], |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * @param DatabaseNotificationInterface $notification |
| 87 | - * @param null $now |
|
| 87 | + * @param null|\DateTime $now |
|
| 88 | 88 | * @param bool $flush |
| 89 | 89 | */ |
| 90 | 90 | public function setReadAtDate(DatabaseNotificationInterface $notification, $now = null, $flush = true) |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | 106 | * @param NotifiableInterface $notifiable |
| 107 | - * @param null $now |
|
| 107 | + * @param \DateTime $now |
|
| 108 | 108 | */ |
| 109 | 109 | public function setUsersNotificationsAsRead(NotifiableInterface $notifiable, $now = null) |
| 110 | 110 | { |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
| 162 | - * @return bool|mixed |
|
| 162 | + * @return string |
|
| 163 | 163 | */ |
| 164 | 164 | protected function notificationEntityName() |
| 165 | 165 | { |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace IrishDan\NotificationBundle\Broadcast; |
| 4 | 4 | |
| 5 | 5 | use IrishDan\NotificationBundle\Channel\ChannelInterface; |
| 6 | -use IrishDan\NotificationBundle\Notification\NotifiableInterface; |
|
| 7 | 6 | use IrishDan\NotificationBundle\Notification\NotificationInterface; |
| 8 | 7 | |
| 9 | 8 | class Broadcaster |