From 5bdc3cc11bde93ea5144afcfc2cf287be3eea1e6 Mon Sep 17 00:00:00 2001 From: Guido Scialfa Date: Sat, 1 Dec 2018 20:11:24 +0100 Subject: [PATCH 1/2] Op code optimizations --- src/BemPrefixed.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BemPrefixed.php b/src/BemPrefixed.php index f04c466..4437d17 100644 --- a/src/BemPrefixed.php +++ b/src/BemPrefixed.php @@ -106,7 +106,7 @@ public function value(): string } // Allow to be used outside of WordPress. - if (function_exists('apply_filters')) { + if (\function_exists('apply_filters')) { /** * Bem Filter * @@ -209,7 +209,7 @@ private function sanitizeHtmlClass(string $class): string { $classes = explode(' ', $class); - if (function_exists('sanitize_html_class')) { + if (\function_exists('sanitize_html_class')) { return implode(' ', array_map('sanitize_html_class', $classes)); } From cc9c273254c6bf2372a2a15f4d0ba3aa2a9e6a0d Mon Sep 17 00:00:00 2001 From: Guido Scialfa Date: Sat, 1 Dec 2018 20:14:37 +0100 Subject: [PATCH 2/2] Don't hardcode filter name, use `&&` conditional operator --- src/BemPrefixed.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/BemPrefixed.php b/src/BemPrefixed.php index 4437d17..100e449 100644 --- a/src/BemPrefixed.php +++ b/src/BemPrefixed.php @@ -36,6 +36,8 @@ */ final class BemPrefixed implements Bem, HasPrefix { + const FILTER_VALUE = 'bem.value'; + /** * Block * @@ -101,7 +103,7 @@ public function value(): string } // Apply the element. - if (!$this->modifiers and $this->element) { + if (!$this->modifiers && $this->element) { $bem .= "__{$this->element}"; } @@ -115,7 +117,7 @@ public function value(): string * @param string $bem The bem value. * @param Bem $this The instance of the class. */ - $bem = apply_filters('bem', $bem, $this); + $bem = apply_filters(self::FILTER_VALUE, $bem, $this); } // Sanitize the class name.