@param DomainEvent $event

@return string
190770
private function whenMethod(DomainEvent $event)
    {
        $classPart = get_class($event);

        if (($pos = strrpos($classPart, '\\')) !== false) {
            $classPart = substr($classPart, $pos + 1);
        }

        return 'when' . ucfirst($classPart);
    }
180929
protected function formatEventError(Event $event)
    {
        return $event->description
            . '('
            . $event->getCommandForDisplay()
            . ') '
            . PHP_EOL
            . $event->wholeOutput()
            . PHP_EOL;
    }
779540
public function onRequestComplete(Event $event)
	{
		if ($body = $event['response']->getBody()) {
			if (substr($body, 0, 3) === "\xef\xbb\xbf") {
				// UTF-8
				$event['response']->setBody(substr($body, 3));
			} else if (substr($body, 0, 4) === "\xff\xfe\x00\x00" ||
					   substr($body, 0, 4) === "\x00\x00\xfe\xff"
			) {
				// UTF-32
				$event['response']->setBody(substr($body, 4));
			} else if (substr($body, 0, 2) === "\xff\xfe" ||
					   substr($body, 0, 2) === "\xfe\xff"
			) {
				// UTF-16
				$event['response']->setBody(substr($body, 2));
			}
		}
	}
916035
public function getEvent($event) : Event {
        return isset($this->registeredEvents[$event]) ? $this->registeredEvents[$event] : null;
    }
624535
public static function generateEventId( $event )
    {
        return hash( 'sha256', $event->getSource()->getId() . getmypid() . microtime( true ) ) . '.' . self::$_lastEventId++;
    }
423066
public function getEventTitle(array $event = []): string
    {
        $extra = [];

        if (!empty($event['calendar_attendees'])) {
            foreach ($event['calendar_attendees'] as $att) {
                if ($att instanceof EntityInterface) {
                    array_push($extra, $att->get('display_name'));
                }
            }
        }

        if (!empty($extra)) {
            $event['title'] .= ' - ' . implode("\n", $extra);
        }

        return $event['title'];
    }
700596
protected function _getIdentifier(\Zend_EventManager_EventDescription $event)
    {
        $params = $event->getParams();
        if(!isset($params['id'])) {
            throw new \Zend_EventManager_Exception_InvalidArgumentException('Missing param id.');
        }

        return md5($this->_getClassName($event->getTarget()) . '-' . $params['id']);
    }
422051
protected <T extends DomainEvent> T registerEvent(T event) {
        Assert.notNull(event, "Domain event must not be null!");

        this.domainEvents.add(event);
        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;
    }
1025829
private function parseName($event)
    {
        if ($event instanceof EventEnvelopeInterface) {
            return $event->getEventName();
        }

        if (is_object($event)) {
            $class = get_class($event);
        } elseif (is_string($event)) {
            $class = $event;
        } else {
            throw new \InvalidArgumentException(sprintf('Cannot parse name for type %s', gettype($event)));
        }

        if (substr($class, -5) === 'Event') {
            $class = substr($class, 0, -5);
        }

        $parts = explode('\\', $class);

        return end($parts);
    }
62208
protected function applyEventCreated(
        EventCreated $eventCreated,
        DomainMessage $domainMessage
    ) {
        $eventId = $eventCreated->getEventId();

        $location = $eventCreated->getLocation();

        $this->addNewItemToIndex(
            $domainMessage,
            $eventId,
            EntityType::EVENT(),
            $eventCreated->getTitle(),
            $location->getAddress()->getPostalCode(),
            $location->getAddress()->getLocality(),
            $location->getAddress()->getCountry()->getCode()
        );
    }
729264
public function col_component($event) {
        // Component.
        $componentname = $event->component;
        if (($event->component === 'core') || ($event->component === 'legacy')) {
            return  get_string('coresystem');
        } else if (get_string_manager()->string_exists('pluginname', $event->component)) {
            return get_string('pluginname', $event->component);
        } else {
            return $componentname;
        }
    }
239272
protected function getEventMessage(Event $event)
    {
        $sanitizedText = $this->getSanitizedText($event);

        $message = sprintf(
            "_e{%d,%d}:%s|%s|d:%d|h:%s|t:%s",
            strlen($event->getTitle()),
            strlen($sanitizedText),
            $event->getTitle(),
            $sanitizedText,
            $event->getTimeStamp(),
            $event->getHost(),
            $event->getType()
        );

        return $message . $this->getFormattedTags($event);
    }
608616
public function serialize(DomainEventStream $domainEventStream)
    {
        $serializedDomainMessages = [];
        foreach ($domainEventStream as $domainMessage) {
            $serializedDomainMessages[] = $this->serializer->serialize($domainMessage);
        }

        return json_encode($serializedDomainMessages);
    }
932673
public function deserialize(array $serialized): DomainEvent {
        $className = $this->classNameForEvent($serialized['eventName']);

        $reflect = new ReflectionClass($className);
        $const = $reflect->getConstructor();

        // reflect on constructor to get name / type
        $constParams = [];
        foreach ($const->getParameters() as $param) {
            $constParams[] = [
                $param->getType()->getName(),
                $param->getName(),
            ];
        }

        // get the values for the constructor fields from the serialized event
        $constParamValues = [];
        foreach ($constParams as $constParam) {
            list($type, $name) = $constParam;
            $fields = $serialized['fields'];
            if ( ! isset($fields[$name])) {
                throw new \Exception("Cannot find serialized field {$name} for {$className}.");
            }
            $constParamValues[] = [
                $type,
                $name,
                $fields[$name],
            ];
        }

        // reconstruct the serialized values into the correct type
       return new $className(...array_map([$this, 'deserializeField'], $constParamValues));
    }
1036694
private function getTypeAndPattern($event)
    {
        $type    = 'text';
        $pattern = '';

        // For Text Message
        if (isset($event['message']) && isset($event['message']['text'])) {
            $pattern = $event['message']['text'];
        }

        // For Attachment Message
        if (isset($event['message']) && isset($event['message']['attachments'])) {
            $type = 'attachment';

            if (isset($event['message']['attachments'][0]['type'])) {
                $pattern = $event['message']['attachments'][0]['type'];
            }
        }

        // For Payload Message
        if (isset($event['postback']['payload'])) {
            $type    = 'payload';
            $pattern = $event['postback']['payload'];
        }

        // For Quick Replies
        if (isset($event['message']) && isset($event['message']['quick_reply']) &&
            !empty($event['message']['quick_reply']['payload'])) {
            $type    = 'payload';
            $pattern = $event['message']['quick_reply']['payload'];
        }

        return compact('type', 'pattern');
    }
32050
public function getEvent($event = [])
    {
        if (!$this->event) {
            $this->event = $event;
            if (isset($event['config'])
                && (empty($event['integration'])
                    || (
                        !empty($event['integration'])
                        && $event['integration'] == $this->getName()
                    )
                )
            ) {
                $this->event['config'] = array_merge($this->settings->getFeatureSettings(), $event['config']);
            }

            if (isset($this->event['campaignEvent']) && !empty($this->event['campaignEvent'])) {
                $campaignEvent             = $this->event['campaignEvent'];
                $this->event['id']         = $campaignEvent['id'];
                $this->event['campaignId'] = $campaignEvent['campaign']['id'];
            }

            // If the campaign event ID is missing, backfill it.
            if (!isset($this->event['id']) || !is_numeric($this->event['id'])) {
                try {
                    $identityMap = $this->em->getUnitOfWork()->getIdentityMap();
                    if (isset($identityMap['Mautic\CampaignBundle\Entity\Event'])) {
                        if (isset($identityMap['Mautic\CampaignBundle\Entity\Campaign']) && !empty($identityMap['Mautic\CampaignBundle\Entity\Campaign'])) {
                            $memoryCampaign = end($identityMap['Mautic\CampaignBundle\Entity\Campaign']);
                            $campaignId     = $memoryCampaign->getId();

                            /** @var \Mautic\CampaignBundle\Entity\Event $leadEvent */
                            foreach ($identityMap['Mautic\CampaignBundle\Entity\Event'] as $leadEvent) {
                                $properties = $leadEvent->getProperties();
                                $campaign   = $leadEvent->getCampaign();
                                if (
                                    $properties['_token'] === $this->event['_token']
                                    && $campaignId == $campaign->getId()
                                ) {
                                    $this->event['id']         = $leadEvent->getId();
                                    $this->event['name']       = $leadEvent->getName();
                                    $this->event['campaignId'] = $campaign->getId();
                                    break;
                                }
                            }
                        }
                    }
                } catch (\Exception $e) {
                }
            }
        }

        return $this->event;
    }