From ea82c4f205b9b7d23a7b1e75d21de976f3627938 Mon Sep 17 00:00:00 2001
From: Piotr Potrebka <piotr.potrebka@wpdesk.net>
Date: Wed, 1 Feb 2023 12:43:04 +0100
Subject: [PATCH] feat: email abstract

---
 src/Abstracts/EmailAbstract.php  | 7 +++++++
 src/Abstracts/EmailInterface.php | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/src/Abstracts/EmailAbstract.php b/src/Abstracts/EmailAbstract.php
index 587caaf..4b2612e 100644
--- a/src/Abstracts/EmailAbstract.php
+++ b/src/Abstracts/EmailAbstract.php
@@ -58,6 +58,9 @@ abstract class EmailAbstract implements EmailInterface {
      */
     abstract public function get_id(): string;
 
+    /**
+     * @return string
+     */
     public function get_template_name(): string {
         return 'default';
     }
@@ -298,6 +301,10 @@ abstract class EmailAbstract implements EmailInterface {
      * @return array|string|string[]
      */
     protected function replace_placeholders( string $string ): string {
+        if ( empty( $this->placeholders ) ) {
+            return $string;
+        }
+
         return (string) str_replace( array_keys( $this->placeholders ), array_values( $this->placeholders ), $string );
     }
 
diff --git a/src/Abstracts/EmailInterface.php b/src/Abstracts/EmailInterface.php
index 35e9469..61a4ea8 100644
--- a/src/Abstracts/EmailInterface.php
+++ b/src/Abstracts/EmailInterface.php
@@ -11,6 +11,13 @@ interface EmailInterface {
      */
     public function get_id(): string;
 
+    /**
+     * Get template name.
+     *
+     * @return string
+     */
+    public function get_template_name(): string;
+
     /**
      * @return string
      */
-- 
GitLab