@param $event

@return Message
487838
protected function buildMessage($event)
    {
        $builder = new MessageBuilder();

        $builder->setUsername("Comment on PR");
        $builder->createAttachment()
            ->setColor('#C9C9C9')
            ->setText($event->comment->body)
            ->setTitle(
                "#%s %s by %s",
                $event->issue->number,
                $event->issue->title,
                $event->issue->user->login
            )
            ->setTitleLink($event->comment->html_url)
            ->setThumbUrl($event->comment->user->avatar_url)
            ->addField("Repository", $event->repository->full_name, true)
            ->addField("Comment by", $event->comment->user->login, true)
            ->attach();

        return $builder->getMessage();
    }
202747
protected function ensureEvent($event): Event
    {
        if (Assert::instanceOf($event, '\\One\\Event\\Event')) {
            return $event;
        } elseif (Assert::string($event)) {
            return new Event($event);
        }

        throw new InvalidArgumentException(
            '`Event` must be `string` or extends class `One\Event\Event`'
        );
    }
190519
public function processStream($event)
    {
        /**
         * @var Request $event->message
         */
        
        if($event->message->isCtlFrame()) {
            if($event->message->isCloseFrame()) {
                return $this->processClose($event);
            }else if($event->message->isPingFrame()){
                return $this->processPing($event);
            }else if($event->message->isPongFrame()){
                return $this->processPong($event);
            }
            
        }else{
            return $this->processData($event);
        }
    }
264390
public function dispatchEvent(object $event): object
    {
        if (isset($this->i__dispatcher)) {
            $this->i__dispatcher->dispatch($event);
        }

        return $event;
    }
85211
public function setEvent($event)
  {
    if ($event === '?' || $event === '') {
      $this->event = null;
    } else {
      $event = Util::foreignLettersToEnglishLetters($event);
      $event = Util::titleCaseIfCurrentlyAllCaps($event);
      $this->event = $event === '?' ? null : $event;
    }
  }
1228410
private function getEventLevel(Event $event)
    {
        $type = $event->getType();

        switch ($type) {
            case Event::INFO:    return LogLevel::INFO;
            case Event::SUCCESS: return LogLevel::NOTICE;
            case Event::WARNING: return LogLevel::WARNING;
            case Event::ERROR:   return LogLevel::ERROR;
        }

        throw new \InvalidArgumentException("$type is not a valid event type");
    }
958954
public function handle($event)
    {
        $eventName = $this->getEventName($event);

        if ($this->listenerIsRegistered($eventName))
        {
            return call_user_func([$this, 'when'.$eventName], $event);
        }
    }
1050926
public function send($event)
    {
        $order = $event->model;
        $mail = $order->orderStatus->mail;
        $smsTemplate = $order->orderStatus->smsTemplate;

        if (!empty($mail)) {
            try {

                /**
                 * @var $mailTemplate Template
                 */
                $mailTemplate = Yii::$app->get('emailTemplates')->getTemplate($mail->key, Language::getCurrent()->id);
                $vars = [
                    '{order_id}' => $order->uid,
                    '{order_sum}' => $order->total_cost,
                    '{created_at}' => $order->creation_time,
                    '{status}' => $order->orderStatus->translation->title,
                    '{order_invoice}' => $order->invoice,
                    '{order_pay_btn}' => $order->invoice
                        ? Html::tag('p', Html::a(Yii::t('order.mail', 'Pay'), $order->invoice, [
                            'target' => '_blank',
                            'style' => [
                                'background-color' => '#f09020',
                                'color' => '#ffffff',
                                'font-size' => '20px',
                                'padding' => '7px 13px',
                                'text-decoration' => 'none',
                                'border-radius' => '4px'
                            ]
                        ]), [
                            'style' => [
                                'text-align' => 'center'
                            ]
                        ])
                        : ''
                ];
                $mailTemplate->parseSubject($vars);
                $mailTemplate->parseBody($vars);

                Yii::$app->shopMailer->compose('mail-body',
                    ['bodyContent' => $mailTemplate->getBody()])
                    ->setFrom([\Yii::$app->cart->sender ?? \Yii::$app->shopMailer->transport->getUsername() => \Yii::$app->name ?? Url::to(['/'], true)])
                    ->setTo($order->user->email)
                    ->setSubject($mailTemplate->getSubject())
                    ->send();

            } catch (Exception $ex) {
                throw new Exception($ex);
            }
        }

        if(!empty($smsTemplate)) {
            $vars = [
                '{order_id}' => $order->uid,
                '{order_sum}' => $order->total_cost,
                '{order_invoice}' => Yii::$app->urlShortener->shorten($order->invoice)
            ];

            /** @var SmsMobizoneComponent $smsComponent */
            $smsComponent = Yii::$app->sms;
            $smsComponent->setSmsText(strtr($smsTemplate->translation->subject, $vars));
            $smsComponent->setRecipientPhoneNumber($order->user->profile->phone);
            $smsComponent->send();
        }
    }
935320
public static function process($event)
    {
        // Link Lead with User
        if ($event->account_linking->status === 'linked') {
            $authorization_code = $event->account_linking->authorization_code;
            $user_id = str_replace('user_id:', '', $authorization_code);
            
            return self::linkWithExistingUser($event->sender->id, $user_id);
        } // Unlink, Logout user
        
        return self::unlinkWithExistingUser($event->sender->id);
    }
51563
public function emitEvent($event)
    {
        if (array_key_exists($event, $this->listeners)) {
            $arg_list = func_get_args();
            array_shift($arg_list);
            foreach ($this->listeners[$event] as $callback) {
                call_user_func_array($callback, $arg_list);
            }
        }

        return $this;
    }
259026
protected function getPayloadFromEvent($event)
    {
        if (method_exists($event, 'broadcastWith')) {
            return array_merge(
                $event->broadcastWith(), ['socket' => data_get($event, 'socket')]
            );
        }

        $payload = [];

        foreach ((new ReflectionClass($event))->getProperties(ReflectionProperty::IS_PUBLIC) as $property) {
            $payload[$property->getName()] = $this->formatProperty($property->getValue($event));
        }

        unset($payload['broadcastQueue']);

        return $payload;
    }
1123669
public function emit($event)
    {
        $emitter = $this->getEmitter();
        $arguments = [$event] + func_get_args();

        return call_user_func_array([$emitter, 'emit'], $arguments);
    }
217054
public function getListeners($event = null){
        if (!$event){
            return $this->listeners;
        }
        return isset($this->listeners[$event]) ? $this->listeners[$event] : null;
    }
866059
public function createFromSerializedEvent(SerializedEvent $event)
    {
        return new Event(
            $event->getId(),
            $event->getName(),
            $this->serializer->deserialize(
                $event->getName(),
                $event->getPayload()
            ),
            $event->getPayloadVersion(),
            $event->getVersion(),
            $event->getDate()
        );
    }
195226
public function onDelete(Event\Delete $event)
    {
        $success = $event->getUser()->delete();
        $event->setResult( (bool)$success );
        if( $event->getResult() === false )
        {
            $event->stopPropagation(true);
        }
        return $event;
    }
43092
protected function ensureEvent($event)
    {
        if (is_string($event)) {
            return Event::named($event);
        }

        if (! $event instanceof EventInterface) {
            throw new InvalidArgumentException('Events should be provides as Event instances or string, received type: '.gettype($event));
        }

        return $event;
    }
16566
public function process(array $event)
    {
        $bytes     = memory_get_usage($this->realUsage);
        $formatted = $this->formatBytes($bytes);

        $event['extra'] = array_merge(
            $event['extra'],
            ['memory_usage' => $formatted]
        );

        return $event;
    }