Skip to content
This repository was archived by the owner on Aug 16, 2022. It is now read-only.

Commit a2c17b9

Browse files
committed
Initial draft commit
0 parents  commit a2c17b9

12 files changed

+611
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/vendor
2+
/.idea
3+
/composer.lock

LICENSE

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2017 Quartzy, Inc.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

composer.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "quartzy/php-email",
3+
"type": "library",
4+
"version": "0.1.0",
5+
"license": "Apache-2.0",
6+
"description": "A domain model for describing emails that is indifferent towards sending methods.",
7+
"keywords": ["email", "domain-driven"],
8+
"authors": [
9+
{
10+
"name": "Chris Muthig",
11+
"email": "camuthig@gmail.com"
12+
}
13+
],
14+
"require": {
15+
"php": "^5.6|^7.0",
16+
"beberlei/assert": "^2.7"
17+
},
18+
"require-dev": {
19+
"phpunit/phpunit": "^5.7"
20+
},
21+
"autoload": {
22+
"psr-4": {
23+
"Postcard\\": "src/"
24+
}
25+
},
26+
"autoload-dev": {
27+
"psr-4": {
28+
"Postcard\\Test\\": "tests/"
29+
}
30+
}
31+
}

src/Content.php

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Postcard;
4+
5+
/**
6+
* A blank interface to defining a hierarchy of email content. In a world with a multitude of third-party services for
7+
* sending email, the content is no longer necessarily and HTML or text string. From here, anything can be defined,
8+
* including emails based on third-party templates, text, or no content at all.
9+
*/
10+
interface Content
11+
{
12+
}

src/Content/EmptyContent.php

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace Postcard\Content;
4+
5+
use Postcard\Content;
6+
7+
class EmptyContent implements Content
8+
{
9+
}

src/Content/SimpleContent.php

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
namespace Postcard\Content;
4+
5+
use Postcard\Content;
6+
7+
/**
8+
* The standard content of an email, as we have always used it. All that is required is some HTML or a text string.
9+
*/
10+
class SimpleContent implements Content
11+
{
12+
/**
13+
* @var string|null
14+
*/
15+
private $html;
16+
17+
/**
18+
* @var string|null
19+
*/
20+
private $text;
21+
22+
/**
23+
* SimpleContent constructor.
24+
*
25+
* @param string|null $html
26+
* @param string|null $text
27+
*/
28+
public function __construct($html, $text)
29+
{
30+
$this->html = $html;
31+
$this->text = $text;
32+
}
33+
34+
/**
35+
* @param string $html
36+
*
37+
* @return self
38+
*/
39+
public static function html($html)
40+
{
41+
return new self($html, null);
42+
}
43+
44+
/**
45+
* @param string $text
46+
*
47+
* @return self
48+
*/
49+
public static function text($text)
50+
{
51+
return new self(null, $text);
52+
}
53+
54+
/**
55+
* @return string|null
56+
*/
57+
public function getHtml()
58+
{
59+
return $this->html;
60+
}
61+
62+
/**
63+
* @return string|null
64+
*/
65+
public function getText()
66+
{
67+
return $this->text;
68+
}
69+
}

src/Content/TemplatedContent.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Postcard\Content;
4+
5+
/**
6+
* Email templates allow rendering of content to be handled by third-party service providers such as Postmark,
7+
* Sparkpost and SendGrid. How an application stores the available third-party templates is up to the developer,
8+
* so the goal of this interface is to give a standard interaction with some templated email content, knowing that a
9+
* template must have an identifier provided by the third party service.
10+
*/
11+
interface TemplatedContent
12+
{
13+
/**
14+
* @return string
15+
*/
16+
public function getTemplateId();
17+
}

0 commit comments

Comments
 (0)