コード例 #1
0
 /**
  * Handles event if the apply method is available
  *
  * This method delegates to a protected method based on the domain event
  * class name: 'apply'.$className
  *
  * @param DomainEvent $domainEvent The domain event
  *
  * @return void
  */
 protected function handle(DomainEvent $domainEvent)
 {
     $method = 'apply' . ClassName::short($domainEvent);
     if (!method_exists($this, $method)) {
         return;
     }
     $this->{$method}($domainEvent);
 }
コード例 #2
0
ファイル: CommandLogger.php プロジェクト: novuso/common-l
 /**
  * {@inheritdoc}
  */
 public function process(CommandMessage $message, callable $next)
 {
     $command = ClassName::short($message->payloadType()->toString());
     try {
         $this->logger->debug(sprintf('Command (%s) received: %s', $command, date(DATE_ATOM)), ['message' => $message->toString()]);
         $next($message);
         $this->logger->debug(sprintf('Command (%s) handled: %s', $command, date(DATE_ATOM)), ['message' => $message->toString()]);
     } catch (Exception $exception) {
         $this->logger->error(sprintf('Command (%s) failed: %s', $command, date(DATE_ATOM)), ['message' => $message->toString(), 'exception' => $exception]);
         throw $exception;
     }
 }
コード例 #3
0
ファイル: QueryLogger.php プロジェクト: novuso/common-l
 /**
  * {@inheritdoc}
  */
 public function process(QueryMessage $message, callable $next)
 {
     $query = ClassName::short($message->payloadType()->toString());
     try {
         $this->logger->debug(sprintf('Query (%s) received: %s', $query, date(DATE_ATOM)), ['message' => $message->serialize()]);
         $data = $next($message);
         $this->logger->debug(sprintf('Query (%s) handled: %s', $query, date(DATE_ATOM)), ['message' => $message->serialize()]);
     } catch (Exception $exception) {
         $this->logger->error(sprintf('Query (%s) failed: %s', $query, date(DATE_ATOM)), ['message' => $message->serialize(), 'exception' => $exception]);
         throw $exception;
     }
     return $data;
 }
コード例 #4
0
ファイル: Enum.php プロジェクト: novuso/system
 /**
  * Retrieves a string representation
  *
  * @return string
  */
 public final function toString() : string
 {
     return sprintf('%s.%s', ClassName::short(static::class), $this->name());
 }
コード例 #5
0
ファイル: ClassNameTest.php プロジェクト: novuso/system
 public function test_that_short_returns_expected_value()
 {
     $expected = 'ClassName';
     $className = 'Novuso\\System\\Utility\\ClassName';
     $this->assertSame($expected, ClassName::short($className));
 }