Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WP Mail
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wpdesk
Library
WP Mail
Commits
6290b817
Commit
6290b817
authored
2 years ago
by
Piotr Potrebka
Browse files
Options
Downloads
Patches
Plain Diff
feat: email abstract
parent
de65272a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Devel
Pipeline
#150949
passed with stages
in 55 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Abstracts/EmailAbstract.php
+114
-3
114 additions, 3 deletions
src/Abstracts/EmailAbstract.php
with
114 additions
and
3 deletions
src/Abstracts/EmailAbstract.php
+
114
−
3
View file @
6290b817
...
...
@@ -2,20 +2,25 @@
namespace
WPDesk\Library\WPEmail\Abstracts
;
use
Exception
;
abstract
class
EmailAbstract
implements
EmailInterface
{
/**
* @var array
*/
protected
$recipients
=
[];
/**
* @var array
*/
protected
$placeholders
=
[];
/**
* @var string
*/
protected
$subject
=
''
;
/**
* @var string
*/
...
...
@@ -48,6 +53,19 @@ abstract class EmailAbstract implements EmailInterface {
*/
abstract
public
function
get_id
():
string
;
/**
* Set placeholders.
*
* @param array $placeholders
*
* @return self
*/
public
function
set_placeholders
(
array
$placeholders
=
[]
):
self
{
$this
->
placeholders
=
array_merge
(
$this
->
placeholders
,
$placeholders
);
return
$this
;
}
/**
* Get defined placeholders.
*
...
...
@@ -57,20 +75,46 @@ abstract class EmailAbstract implements EmailInterface {
return
$this
->
placeholders
;
}
/**
* Get email subject.
*
* @param string $subject
*
* @return self
*/
public
function
set_subject
(
string
$subject
):
self
{
$this
->
subject
=
$subject
;
return
$this
;
}
/**
* Get email subject.
*
* @return string
* @throws
\
Exception
* @throws Exception
*/
public
function
get_subject
():
string
{
if
(
!
$this
->
subject
)
{
throw
new
\
Exception
(
'Empty email subject'
);
throw
new
Exception
(
'Empty email subject'
);
}
return
$this
->
subject
;
}
/**
* Set email heading.
*
* @param string $heading
*
* @return self
*/
public
function
set_heading
(
string
$heading
):
self
{
$this
->
heading
=
$heading
;
return
$this
;
}
/**
* Get email heading.
*
...
...
@@ -80,6 +124,19 @@ abstract class EmailAbstract implements EmailInterface {
return
$this
->
heading
;
}
/**
* Get valid recipients.
*
* @param array $recipients
*
* @return self
*/
public
function
set_recipients
(
array
$recipients
=
[]
):
self
{
$this
->
recipients
=
$recipients
;
return
$this
;
}
/**
* Get valid recipients.
*
...
...
@@ -89,6 +146,19 @@ abstract class EmailAbstract implements EmailInterface {
return
$this
->
recipients
;
}
/**
* Get email headers.
*
* @param array $headers
*
* @return self
*/
public
function
set_headers
(
array
$headers
=
[]
):
self
{
$this
->
headers
=
$headers
;
return
$this
;
}
/**
* Get email headers.
*
...
...
@@ -98,6 +168,19 @@ abstract class EmailAbstract implements EmailInterface {
return
$this
->
headers
;
}
/**
* Set attachments.
*
* @param array $attachments
*
* @return self
*/
public
function
set_attachments
(
array
$attachments
):
self
{
$this
->
attachments
=
$attachments
;
return
$this
;
}
/**
* Get email attachments.
*
...
...
@@ -107,6 +190,19 @@ abstract class EmailAbstract implements EmailInterface {
return
$this
->
attachments
;
}
/**
* Set email type.
*
* @param string $type
*
* @return self
*/
public
function
set_type
(
string
$type
=
'text/html'
):
self
{
$this
->
type
=
$type
;
return
$this
;
}
/**
* Get email type.
*
...
...
@@ -116,14 +212,28 @@ abstract class EmailAbstract implements EmailInterface {
return
$this
->
type
;
}
/**
* Get email content.
*
* @param string $content
*
* @return self
*/
public
function
set_content
(
string
$content
):
self
{
$this
->
content
=
$content
;
return
$this
;
}
/**
* Get email content.
*
* @return string
* @throws Exception
*/
public
function
get_content
():
string
{
if
(
!
$this
->
content
)
{
throw
new
\
Exception
(
'Empty email
subjec
t'
);
throw
new
Exception
(
'Empty email
conten
t'
);
}
return
''
;
...
...
@@ -136,4 +246,5 @@ abstract class EmailAbstract implements EmailInterface {
return
''
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment