From 267cad1eb4f440aa0c13c12ecb2002f8fa7361f6 Mon Sep 17 00:00:00 2001 From: Y!an Date: Mon, 9 Sep 2019 23:48:30 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +- src/Auto.php | 30 +++++--------- src/Base.php | 82 +++++++++++++-------------------------- src/Encryptor.php | 37 +++++++----------- src/Event/Base.php | 4 +- src/Event/Click.php | 10 ++--- src/Event/Location.php | 10 ++--- src/Event/Scan.php | 11 ++---- src/Event/Subscribe.php | 10 ++--- src/Event/Unsubscribe.php | 4 +- src/Event/View.php | 10 ++--- src/Image.php | 10 ++--- src/Link.php | 10 ++--- src/Location.php | 10 ++--- src/Music.php | 10 ++--- src/News.php | 14 +++---- src/ShortVideo.php | 10 ++--- src/Text.php | 10 ++--- src/Video.php | 10 ++--- src/Voice.php | 10 ++--- 20 files changed, 114 insertions(+), 191 deletions(-) diff --git a/.gitignore b/.gitignore index 4f4acd3..8a52ffd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ vendor/ -composer.lock \ No newline at end of file +composer.lock +.php_cs.cache \ No newline at end of file diff --git a/src/Auto.php b/src/Auto.php index aa1096b..1bab2a7 100644 --- a/src/Auto.php +++ b/src/Auto.php @@ -2,7 +2,7 @@ /** * 自动识别消息类型类 - * + * * @package Lychee\Message * @author Y!an */ @@ -41,39 +41,29 @@ public static function init(string $xml) $doc->loadXML($xml); $msgType = $doc->getElementsByTagName("MsgType"); - if (! $msgType->length) - { + if (! $msgType->length) { throw new \Exception("Invalid msg"); } $msgType = $msgType->item(0)->nodeValue; $className = "Lychee\\Message\\"; - if ($msgType == "event") - { + if ($msgType == "event") { $event = $doc->getElementsByTagName("Event"); - if (! $event->length) - { + if (! $event->length) { throw new \Exception("Invalid msg"); } $event = $event->item(0)->nodeValue; - if (in_array($event, $eventList)) - { + if (in_array($event, $eventList)) { $className .= "Event\\" . ucfirst($event); return new $className($xml); } throw new \Exception("Invalid msg"); - } - else - { - if (in_array($msgType, $typeList)) - { - if ($msgType == "shortvideo") - { + } else { + if (in_array($msgType, $typeList)) { + if ($msgType == "shortvideo") { $className .= "ShortVideo"; - } - else - { + } else { $className .= ucfirst($msgType); } return new $className($xml); @@ -81,4 +71,4 @@ public static function init(string $xml) throw new \Exception("Invalid msg"); } } -} \ No newline at end of file +} diff --git a/src/Base.php b/src/Base.php index 03f264b..9efe233 100644 --- a/src/Base.php +++ b/src/Base.php @@ -2,7 +2,7 @@ /** * 消息类基类 - * + * * @package Lychee\Message * @author Y!an */ @@ -65,22 +65,19 @@ abstract class Base public function __construct(string $xml = "") { // 子类继承基类时必须指定 $this->msgtype 的值 - if (is_null($this->msgtype)) - { + if (is_null($this->msgtype)) { throw new \Exception("Message type can not be null"); } // 创建一个空的消息类 - if ($xml == "") - { + if ($xml == "") { return; } // 从 XML 中创建一个消息类 $msgTree = $this->fromXML($xml); - if (! $this->validateProperties($msgTree)) - { + if (! $this->validateProperties($msgTree)) { throw new \Exception("Validate properties failed"); } } @@ -97,29 +94,25 @@ public function fromXML(string $xml): array $doc = new DOMDocument; $doc->loadXML($xml); $msg = $doc->getElementsByTagName("xml"); - if (! $msg->length) - { + if (! $msg->length) { throw new Exception("Invalid msg"); } $msg = $msg->item(0); $msgTree = $this->traverseXML($msg); if (! isset($msgTree['MsgType']) - || $msgTree['MsgType'] != $this->MsgType) - { + || $msgTree['MsgType'] != $this->MsgType) { throw new \Exception("Invalid message type"); } if (! isset($msgTree['FromUserName']) || ! isset($msgTree['ToUserName']) - || ! isset($msgTree['CreateTime'])) - { + || ! isset($msgTree['CreateTime'])) { throw new \Exception("Invalid message"); } $this->FromUserName = $msgTree['FromUserName']; $this->ToUserName = $msgTree['ToUserName']; $this->CreateTime = $msgTree['CreateTime']; $this->MsgId = isset($msgTree['MsgId']) ? $msgTree['MsgId'] : null; - if ($this->MsgType == 'event') - { + if ($this->MsgType == 'event') { $this->Event = $msgTree['Event']; } @@ -133,8 +126,7 @@ public function fromXML(string $xml): array */ public function toXML(): string { - if (! $this->validateProperties($this->properties)) - { + if (! $this->validateProperties($this->properties)) { throw new \Exception("Validate properties failed"); } $base = [ @@ -143,12 +135,10 @@ public function toXML(): string "CreateTime" => $this->CreateTime, "MsgType" => $this->MsgType, ]; - if (! is_null($this->MsgId)) - { + if (! is_null($this->MsgId)) { $base["MsgId"] = $this->MsgId; } - if ($this->MsgType == "event") - { + if ($this->MsgType == "event") { $base["Event"] = $this->Event; } $datas = $base + $this->properties; @@ -171,12 +161,10 @@ public function toArray(): array "ToUserName" => $this->ToUserName, "CreateTime" => $this->CreateTime, ]; - if (! is_null($this->MsgId)) - { + if (! is_null($this->MsgId)) { $base["MsgId"] = $this->MsgId; } - if ($this->MsgType == 'event') - { + if ($this->MsgType == 'event') { $base["Event"] = $this->Event; } return array_merge($base, $this->properties); @@ -186,21 +174,16 @@ private function traverseXML(\DOMElement $element): array { $tree = []; - foreach ($element->childNodes as $node) - { - if (! $node->hasChildNodes()) - { + foreach ($element->childNodes as $node) { + if (! $node->hasChildNodes()) { continue; } - foreach ($node->childNodes as $childElement) - { - if ($childElement->hasChildNodes()) - { + foreach ($node->childNodes as $childElement) { + if ($childElement->hasChildNodes()) { $tree[$node->nodeName][] = $this->traverseXML($childElement); continue; } $tree[$node->nodeName] = $childElement->nodeValue; - } // foreach ($node->childNodes as $childElement) } @@ -215,36 +198,26 @@ private function traverseXML(\DOMElement $element): array */ private function buildXML(array $datas, string $elementName, \DOMDocument $dom = null): \DOMNode { - if (is_null($dom)) - { + if (is_null($dom)) { $dom = new \DOMDocument; } $xmlBody = $dom->createElement($elementName); - foreach ($datas as $name => $dataProperties) - { - if (is_array($dataProperties)) - { - if (is_numeric($name)) - { + foreach ($datas as $name => $dataProperties) { + if (is_array($dataProperties)) { + if (is_numeric($name)) { $name = "item"; } $node = $dom->createElement($name); - foreach ($dataProperties as $n => $property) - { - if (is_numeric($n)) - { + foreach ($dataProperties as $n => $property) { + if (is_numeric($n)) { $n = "item"; } $child = $this->buildXML($property, $n, $dom); $node->appendChild($child); } - } - else if (is_numeric($dataProperties)) - { + } elseif (is_numeric($dataProperties)) { $node = $dom->createElement($name, $dataProperties); - } - else - { + } else { $node = $dom->createElement($name); $nodeValue = $xmlBody->ownerDocument->createCDATASection($dataProperties); $node->appendChild($nodeValue); @@ -304,10 +277,9 @@ public function setMsgId(int $value) public function __get(string $name) { - if (in_array($name, ["ToUserName", "FromUserName", "CreateTime", "MsgType", "MsgId"])) - { + if (in_array($name, ["ToUserName", "FromUserName", "CreateTime", "MsgType", "MsgId"])) { return $this->$name; } return isset($this->properties[$name]) ? $this->properties[$name] : false; } -} \ No newline at end of file +} diff --git a/src/Encryptor.php b/src/Encryptor.php index babf217..cca0174 100644 --- a/src/Encryptor.php +++ b/src/Encryptor.php @@ -2,7 +2,7 @@ /** * 消息加解密类 - * + * * @package Lychee\Message * @author Y!an */ @@ -47,22 +47,19 @@ public function __construct(string $appid, string $token, string $key) * 加密 xml 数据 * * @param string $xml - * + * * @return string - * + * * @throws Exception */ public function encrypt(string $xml): string { - try - { + try { $xml = $this->pkcs7Pad($this->randStr().pack('N', strlen($xml)).$xml.$this->appid, 32); $iv = substr($this->key, 0, 16); $Encrypt = openssl_encrypt($xml, "AES-256-CBC", $this->key, OPENSSL_ZERO_PADDING, $iv); - } - catch (\Throwable $e) - { + } catch (\Throwable $e) { throw new \Exception($e->getMessage()); } $TimeStamp = time(); @@ -87,9 +84,9 @@ public function encrypt(string $xml): string * @param string $sign * @param string $timestamp * @param string $nonce - * + * * @return string - * + * * @throws Exception */ public function decrypt(string $rawXMLData, string $sign, string $timestamp, string $nonce): string @@ -97,14 +94,12 @@ public function decrypt(string $rawXMLData, string $sign, string $timestamp, str $xml = new DOMDocument; $xml->loadXML($rawXMLData); $encrypt = $xml->getElementsByTagName("Encrypt"); - if (! $encrypt->length) - { + if (! $encrypt->length) { throw new \Exception("Invalid data"); } $encrypt = $encrypt->item(0)->nodeValue; - if ($this->sign($this->token, $encrypt, $timestamp, $nonce) != $sign) - { + if ($this->sign($this->token, $encrypt, $timestamp, $nonce) != $sign) { throw new \Exception("Invalid Sign"); } @@ -115,8 +110,7 @@ public function decrypt(string $rawXMLData, string $sign, string $timestamp, str $content = substr($result, 16, strlen($result)); $contentLen = unpack('N', substr($content, 0, 4))[1]; - if (trim(substr($content, $contentLen + 4)) !== $this->appid) - { + if (trim(substr($content, $contentLen + 4)) !== $this->appid) { throw new \Exception('Invalid appid'); } @@ -135,8 +129,7 @@ public function decrypt(string $rawXMLData, string $sign, string $timestamp, str */ public function pkcs7Pad(string $text, int $blockSize): string { - if ($blockSize > 256) - { + if ($blockSize > 256) { throw new Exception('$blockSize may not be more than 256'); } $padding = $blockSize - (strlen($text) % $blockSize); @@ -155,8 +148,7 @@ public function pkcs7Pad(string $text, int $blockSize): string public function pkcs7Unpad(string $text): string { $pad = ord(substr($text, -1)); - if ($pad < 1 || $pad > 32) - { + if ($pad < 1 || $pad > 32) { $pad = 0; } @@ -186,10 +178,9 @@ private function randStr(int $length = 16): string { $dict = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456798"; $str = ""; - for ($i = 0; $i < $length; $i++) - { + for ($i = 0; $i < $length; $i++) { $str .= $dict[mt_rand(0, strlen($dict) - 1)]; } return $str; } -} \ No newline at end of file +} diff --git a/src/Event/Base.php b/src/Event/Base.php index d705704..ecd4bb2 100644 --- a/src/Event/Base.php +++ b/src/Event/Base.php @@ -2,7 +2,7 @@ /** * 事件消息类基类 - * + * * @package Lychee\Message\Event * @author Y!an */ @@ -24,4 +24,4 @@ abstract class Base extends \Lychee\Message\Base * @var string */ protected $Event; -} \ No newline at end of file +} diff --git a/src/Event/Click.php b/src/Event/Click.php index 9043c9d..4ba6996 100644 --- a/src/Event/Click.php +++ b/src/Event/Click.php @@ -2,7 +2,7 @@ /** * 点击菜单事件消息类 - * + * * @package Lychee\Message\Event * @author Y!an */ @@ -28,10 +28,8 @@ protected function validateProperties(array $tree): bool $validateList = [ "EventKey", ]; - foreach ($validateList as $property) - { - if (! isset($tree[$property])) - { + foreach ($validateList as $property) { + if (! isset($tree[$property])) { return false; } $this->properties[$property] = $tree[$property]; @@ -50,4 +48,4 @@ public function setEventKey(string $eventKey) $this->properties["EventKey"] = $eventKey; return $this; } -} \ No newline at end of file +} diff --git a/src/Event/Location.php b/src/Event/Location.php index 6b787f3..7bfe09f 100644 --- a/src/Event/Location.php +++ b/src/Event/Location.php @@ -2,7 +2,7 @@ /** * 上报地理位置事件消息类 - * + * * @package Lychee\Message\Event * @author Y!an */ @@ -30,10 +30,8 @@ protected function validateProperties(array $tree): bool "Longitude", "Precision", ]; - foreach ($validateList as $property) - { - if (! isset($tree[$property])) - { + foreach ($validateList as $property) { + if (! isset($tree[$property])) { return false; } $this->properties[$property] = $tree[$property]; @@ -76,4 +74,4 @@ public function setPrecision(string $precision) $this->properties["Precision"] = $precision; return $this; } -} \ No newline at end of file +} diff --git a/src/Event/Scan.php b/src/Event/Scan.php index 58eae0c..44baea9 100644 --- a/src/Event/Scan.php +++ b/src/Event/Scan.php @@ -2,7 +2,7 @@ /** * 扫描带参二维码事件消息类 - * + * * @package Lychee\Message\Event * @author Y!an */ @@ -29,13 +29,10 @@ protected function validateProperties(array $tree): bool "EventKey", "Ticket", ]; - foreach ($validateList as $property) - { - if (isset($tree[$property])) - { + foreach ($validateList as $property) { + if (isset($tree[$property])) { $this->properties[$property] = $tree[$property]; } - } return true; } @@ -73,4 +70,4 @@ public function setTicket(string $ticket) $this->properties["Ticket"] = $ticket; return $this; } -} \ No newline at end of file +} diff --git a/src/Event/Subscribe.php b/src/Event/Subscribe.php index ffc61ef..effb88e 100644 --- a/src/Event/Subscribe.php +++ b/src/Event/Subscribe.php @@ -2,7 +2,7 @@ /** * 关注事件消息类 - * + * * @package Lychee\Message\Event * @author Y!an */ @@ -29,10 +29,8 @@ protected function validateProperties(array $tree): bool "EventKey", "Ticket", ]; - foreach ($validateList as $property) - { - if (isset($tree[$property])) - { + foreach ($validateList as $property) { + if (isset($tree[$property])) { $this->properties[$property] = $tree[$property]; } } @@ -82,4 +80,4 @@ public function setTicket(string $ticket) $this->properties["Ticket"] = $ticket; return $this; } -} \ No newline at end of file +} diff --git a/src/Event/Unsubscribe.php b/src/Event/Unsubscribe.php index c7a66bc..9f5462c 100644 --- a/src/Event/Unsubscribe.php +++ b/src/Event/Unsubscribe.php @@ -2,7 +2,7 @@ /** * 取消关注事件消息类 - * + * * @package Lychee\Message\Event * @author Y!an */ @@ -27,4 +27,4 @@ protected function validateProperties(array $tree): bool { return true; } -} \ No newline at end of file +} diff --git a/src/Event/View.php b/src/Event/View.php index a1bd421..e9a09b8 100644 --- a/src/Event/View.php +++ b/src/Event/View.php @@ -2,7 +2,7 @@ /** * 点击菜单(链接)事件消息类 - * + * * @package Lychee\Message\Event * @author Y!an */ @@ -28,10 +28,8 @@ protected function validateProperties(array $tree): bool $validateList = [ "EventKey", ]; - foreach ($validateList as $property) - { - if (! isset($tree[$property])) - { + foreach ($validateList as $property) { + if (! isset($tree[$property])) { return false; } $this->properties[$property] = $tree[$property]; @@ -50,4 +48,4 @@ public function setEventKey(string $eventKey) $this->properties["EventKey"] = $eventKey; return $this; } -} \ No newline at end of file +} diff --git a/src/Image.php b/src/Image.php index 16c739e..8328952 100644 --- a/src/Image.php +++ b/src/Image.php @@ -2,7 +2,7 @@ /** * 图片消息类 - * + * * @package Lychee\Message * @author Y!an */ @@ -31,10 +31,8 @@ protected function validateProperties(array $tree): bool $validateList = [ "MediaId", ]; - foreach ($validateList as $property) - { - if (! isset($tree[$property])) - { + foreach ($validateList as $property) { + if (! isset($tree[$property])) { return false; } $this->properties[$property] = $tree[$property]; @@ -66,4 +64,4 @@ public function setPicUrl(string $picUrl) $this->properties["PicUrl"] = $picUrl; return $this; } -} \ No newline at end of file +} diff --git a/src/Link.php b/src/Link.php index fe05ffa..b1bce60 100644 --- a/src/Link.php +++ b/src/Link.php @@ -2,7 +2,7 @@ /** * 链接消息类 - * + * * @package Lychee\Message * @author Y!an */ @@ -33,10 +33,8 @@ protected function validateProperties(array $tree): bool "Description", "Url", ]; - foreach ($validateList as $property) - { - if (! isset($tree[$property])) - { + foreach ($validateList as $property) { + if (! isset($tree[$property])) { return false; } $this->properties[$property] = $tree[$property]; @@ -79,4 +77,4 @@ public function setUrl(string $url) $this->properties["Url"] = $url; return $this; } -} \ No newline at end of file +} diff --git a/src/Location.php b/src/Location.php index c77d2cc..56f720a 100644 --- a/src/Location.php +++ b/src/Location.php @@ -2,7 +2,7 @@ /** * 地理位置消息类 - * + * * @package Lychee\Message * @author Y!an */ @@ -34,10 +34,8 @@ protected function validateProperties(array $tree): bool "Scale", "Label" ]; - foreach ($validateList as $property) - { - if (! isset($tree[$property])) - { + foreach ($validateList as $property) { + if (! isset($tree[$property])) { return false; } $this->properties[$property] = $tree[$property]; @@ -92,4 +90,4 @@ public function setLabel(string $label) $this->properties["Label"] = $label; return $this; } -} \ No newline at end of file +} diff --git a/src/Music.php b/src/Music.php index 66416e0..c0488fb 100644 --- a/src/Music.php +++ b/src/Music.php @@ -2,7 +2,7 @@ /** * 音乐消息类 - * + * * @package Lychee\Message * @author Y!an */ @@ -31,10 +31,8 @@ protected function validateProperties(array $tree): bool $validateList = [ "ThumbMediaId", ]; - foreach ($validateList as $property) - { - if (! isset($tree[$property])) - { + foreach ($validateList as $property) { + if (! isset($tree[$property])) { return false; } $this->properties[$property] = $tree[$property]; @@ -102,4 +100,4 @@ public function setHQMusicUrl(string $HQMusicUrl) $this->properties["HQMusicUrl"] = $HQMusicUrl; return $this; } -} \ No newline at end of file +} diff --git a/src/News.php b/src/News.php index 1e31744..7a57593 100644 --- a/src/News.php +++ b/src/News.php @@ -21,23 +21,19 @@ class News extends Base protected function validateProperties(array $tree): bool { if (! isset($tree["ArticleCount"]) - || ! isset($tree["Articles"])) - { + || ! isset($tree["Articles"])) { return false; } $this->properties["ArticleCount"] = $tree["ArticleCount"]; - for ($i = 0; $i < $tree["ArticleCount"]; $i++) - { + for ($i = 0; $i < $tree["ArticleCount"]; $i++) { $articleElemets = [ "Title", "Description", "PicUrl", "Url" ]; - foreach ($articleElemets as $el) - { - if (! isset($tree["Articles"][$i][$el])) - { + foreach ($articleElemets as $el) { + if (! isset($tree["Articles"][$i][$el])) { return false; } $this->properties["Articles"][$i][$el] = $tree["Articles"][$i][$el]; @@ -45,4 +41,4 @@ protected function validateProperties(array $tree): bool } return true; } -} \ No newline at end of file +} diff --git a/src/ShortVideo.php b/src/ShortVideo.php index 436058f..0e0d27d 100644 --- a/src/ShortVideo.php +++ b/src/ShortVideo.php @@ -2,7 +2,7 @@ /** * 小视频消息类 - * + * * @package Lychee\Message * @author Y!an */ @@ -32,10 +32,8 @@ protected function validateProperties(array $tree): bool "MediaId", "ThumbMediaId" ]; - foreach ($validateList as $property) - { - if (! isset($tree[$property])) - { + foreach ($validateList as $property) { + if (! isset($tree[$property])) { return false; } $this->properties[$property] = $tree[$property]; @@ -66,4 +64,4 @@ public function setThumbMediaId(string $thumbMediaId) $this->properties["ThumbMediaId"] = $thumbMediaId; return $this; } -} \ No newline at end of file +} diff --git a/src/Text.php b/src/Text.php index 1dea1f7..3f9bdcf 100644 --- a/src/Text.php +++ b/src/Text.php @@ -2,7 +2,7 @@ /** * 文字消息类 - * + * * @package Lychee\Message * @author Y!an */ @@ -31,10 +31,8 @@ protected function validateProperties(array $tree): bool $validateList = [ "Content", ]; - foreach ($validateList as $property) - { - if (! isset($tree[$property])) - { + foreach ($validateList as $property) { + if (! isset($tree[$property])) { return false; } $this->properties[$property] = $tree[$property]; @@ -53,4 +51,4 @@ public function setContent(string $text) $this->properties['Content'] = $text; return $this; } -} \ No newline at end of file +} diff --git a/src/Video.php b/src/Video.php index 5187e37..4f7acf7 100644 --- a/src/Video.php +++ b/src/Video.php @@ -2,7 +2,7 @@ /** * 视频消息类 - * + * * @package Lychee\Message * @author Y!an */ @@ -31,10 +31,8 @@ protected function validateProperties(array $tree): bool $validateList = [ "MediaId", ]; - foreach ($validateList as $property) - { - if (! isset($tree[$property])) - { + foreach ($validateList as $property) { + if (! isset($tree[$property])) { return false; } $this->properties[$property] = $tree[$property]; @@ -90,4 +88,4 @@ public function setThumbMediaId(string $thumbMediaId) $this->properties["ThumbMediaId"] = $thumbMediaId; return $this; } -} \ No newline at end of file +} diff --git a/src/Voice.php b/src/Voice.php index 0f8c6e8..dba353d 100644 --- a/src/Voice.php +++ b/src/Voice.php @@ -2,7 +2,7 @@ /** * 语音消息类 - * + * * @package Lychee\Message * @author Y!an */ @@ -31,10 +31,8 @@ protected function validateProperties(array $tree): bool $validateList = [ "MediaId", ]; - foreach ($validateList as $property) - { - if (! isset($tree[$property])) - { + foreach ($validateList as $property) { + if (! isset($tree[$property])) { return false; } $this->properties[$property] = $tree[$property]; @@ -78,4 +76,4 @@ public function setRecognition(string $recognition) $this->properties["Recognition"] = $recognition; return $this; } -} \ No newline at end of file +} From 88ffc22e0cde7809e0f37617ed28a9f365c1130e Mon Sep 17 00:00:00 2001 From: Y!an Date: Tue, 10 Sep 2019 01:08:15 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=AF=BC=E8=87=B4=E6=8A=9B=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Auto.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Auto.php b/src/Auto.php index 1bab2a7..0443f03 100644 --- a/src/Auto.php +++ b/src/Auto.php @@ -53,7 +53,7 @@ public static function init(string $xml) if (! $event->length) { throw new \Exception("Invalid msg"); } - $event = $event->item(0)->nodeValue; + $event = strtolower($event->item(0)->nodeValue); if (in_array($event, $eventList)) { $className .= "Event\\" . ucfirst($event); return new $className($xml);