Skip to content

Commit f25f8c6

Browse files
authored
ci: switch to github actions (#88)
1 parent 4b96a55 commit f25f8c6

File tree

6 files changed

+65
-54
lines changed

6 files changed

+65
-54
lines changed

.github/workflows/ci.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: ci
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
phpunit:
11+
runs-on: "ubuntu-20.04"
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
php-version:
17+
- "7.4"
18+
- "8.0"
19+
- "8.1"
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
24+
- name: "Install PHP ${{ matrix.php-version }}"
25+
uses: "shivammathur/setup-php@v2"
26+
with:
27+
php-version: "${{ matrix.php-version }}"
28+
coverage: "pcov"
29+
30+
- name: "Install dependencies with Composer"
31+
uses: "ramsey/composer-install@v1"
32+
33+
- name: "Run PHPUnit"
34+
run: "vendor/bin/simple-phpunit --coverage-text"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
vendor/
22
composer.lock
3+
.phpunit.result.cache

.travis.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

README.md

Lines changed: 24 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
EmailReplyParser
2-
================
1+
# EmailReplyParser
32

4-
[![Build
5-
Status](https://secure.travis-ci.org/willdurand/EmailReplyParser.png)](http://travis-ci.org/willdurand/EmailReplyParser)
3+
[![GitHub Actions](https://github.com/willdurand/EmailReplyParser/workflows/ci/badge.svg)](https://github.com/willdurand/EmailReplyParser/actions?query=workflow%3A%22ci%22+branch%3Amaster)
64
[![Total
75
Downloads](https://poser.pugx.org/willdurand/email-reply-parser/downloads.png)](https://packagist.org/packages/willdurand/email-reply-parser)
86
[![Latest Stable
@@ -12,23 +10,20 @@ Version](https://poser.pugx.org/willdurand/email-reply-parser/v/stable.png)](htt
1210
based on GitHub's [email_reply_parser](http://github.com/github/email_reply_parser)
1311
library written in Ruby.
1412

15-
16-
Installation
17-
------------
13+
## Installation
1814

1915
The recommended way to install EmailReplyParser is through
2016
[Composer](http://getcomposer.org/):
2117

22-
``` shell
18+
```shell
2319
composer require willdurand/email-reply-parser
2420
```
2521

26-
Usage
27-
-----
22+
## Usage
2823

2924
Instantiate an `EmailParser` object and parse your email:
3025

31-
``` php
26+
```php
3227
<?php
3328

3429
use EmailReplyParser\Parser\EmailParser;
@@ -39,14 +34,14 @@ $email = (new EmailParser())->parse($emailContent);
3934
You get an `Email` object that contains a set of `Fragment` objects. The `Email`
4035
class exposes two methods:
4136

42-
* `getFragments()`: returns all fragments;
43-
* `getVisibleText()`: returns a string which represents the content considered
37+
- `getFragments()`: returns all fragments;
38+
- `getVisibleText()`: returns a string which represents the content considered
4439
as "visible".
4540

4641
The `Fragment` represents a part of the full email content, and has the
4742
following API:
4843

49-
``` php
44+
```php
5045
<?php
5146

5247
$fragment = current($email->getFragments());
@@ -65,15 +60,13 @@ $fragment->isEmpty();
6560
Alternatively, you can rely on the `EmailReplyParser` to either parse an email
6661
or get its visible content in a single line of code:
6762

68-
``` php
63+
```php
6964
$email = \EmailReplyParser\EmailReplyParser::read($emailContent);
7065

7166
$visibleText = \EmailReplyParser\EmailReplyParser::parseReply($emailContent);
7267
```
7368

74-
75-
Known Issues
76-
------------
69+
## Known Issues
7770

7871
### Quoted Headers
7972

@@ -84,23 +77,23 @@ Quoted headers aren't picked up if there's an extra line break:
8477
> blah
8578

8679
Also, they're not picked up if the email client breaks it up into
87-
multiple lines. GMail breaks up any lines over 80 characters for you.
80+
multiple lines. GMail breaks up any lines over 80 characters for you.
8881

8982
On <date>, <author>
9083
wrote:
9184
> blah
9285

9386
The above `On ....wrote:` can be cleaned up with the following regex:
9487

95-
``` php
88+
```php
9689
$fragment_without_date_author = preg_replace(
97-
'/\nOn(.*?)wrote:(.*?)$/si',
98-
'',
99-
$fragment->getContent()
90+
'/\nOn(.*?)wrote:(.*?)$/si',
91+
"",
92+
$fragment->getContent()
10093
);
10194
```
10295

103-
Note though that we're search for "on" and "wrote". Therefore, it won't work
96+
Note though that we're search for "on" and "wrote". Therefore, it won't work
10497
with other languages.
10598

10699
Possible solution: Remove "[email protected]" lines...
@@ -127,8 +120,6 @@ Not everyone follows this convention:
127120
* Note: blah blah blah *
128121
**********************DISCLAIMER***********************************
129122

130-
131-
132123
### Strange Quoting
133124

134125
Apparently, prefixing lines with `>` isn't universal either:
@@ -143,34 +134,26 @@ Apparently, prefixing lines with `>` isn't universal either:
143134
Sent: Monday, March 14, 2011 6:16 PM
144135
To: Rick
145136

146-
147-
Unit Tests
148-
----------
137+
## Unit Tests
149138

150139
Setup the test suite using Composer:
151140

152141
$ composer install
153142

154143
Run it using PHPUnit:
155144

156-
$ ./vendor/bin/phpunit
157-
145+
$ ./vendor/bin/simple-phpunit
158146

159-
Contributing
160-
------------
147+
## Contributing
161148

162149
See CONTRIBUTING file.
163150

151+
## Credits
164152

165-
Credits
166-
-------
167-
168-
* GitHub
169-
* William Durand
170-
153+
- GitHub
154+
- William Durand
171155

172-
License
173-
-------
156+
## License
174157

175158
EmailReplyParser is released under the MIT License. See the bundled LICENSE
176159
file for details.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
}
1212
],
1313
"require": {
14-
"php": ">=7.3.0"
14+
"php": ">=7.4.0"
1515
},
1616
"autoload": {
1717
"psr-4": { "EmailReplyParser\\": "src/EmailReplyParser" }
@@ -25,6 +25,6 @@
2525
}
2626
},
2727
"require-dev": {
28-
"phpunit/phpunit": "^9.5"
28+
"symfony/phpunit-bridge": "^5.0"
2929
}
3030
}

src/EmailReplyParser/Parser/EmailParser.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ class EmailParser
6868
*/
6969
public function parse($text)
7070
{
71+
if (!is_string($text)) {
72+
return new Email();
73+
}
74+
7175
$text = str_replace(array("\r\n", "\r"), "\n", $text);
7276

7377
foreach ($this->quoteHeadersRegex as $regex) {

0 commit comments

Comments
 (0)