Skip to content

Commit fee6209

Browse files
author
Damien Debin
committed
Complete ATOM specs, adding missing properties. Source code filly validate PHPStan level 7. 100% code coverage.
1 parent 3c77a75 commit fee6209

12 files changed

Lines changed: 1143 additions & 72 deletions

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ install:
1313
- travis_retry composer install --no-progress --no-interaction --prefer-dist
1414
script:
1515
- ./vendor/bin/php-cs-fixer fix --allow-risky=yes --dry-run -v --stop-on-violation
16+
- ./vendor/bin/phpstan analyse -l 7 -c phpstan.neon src
1617
- composer phpunit

README.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,44 @@
11
[![Build Status](https://travis-ci.org/ddebin/atom-generator.svg?branch=master)](https://travis-ci.org/ddebin/atom-generator)
22

3-
# atom-generator
3+
# Atom feed generator
44

5-
Atom feed generator
5+
This library is an [Atom](https://en.wikipedia.org/wiki/Atom_(Web_standard) feed generator, PHP 7.1+, fully typed ([PHPStan](https://github.com/phpstan/phpstan) level 7, 100% code coverage). Follows W3C standard
6+
([RFC 4287](https://validator.w3.org/feed/docs/rfc4287.html)).
7+
8+
## Installing
9+
10+
To include `mc-google-visualization` in your project, add it to your `composer.json` file:
11+
12+
```json
13+
{
14+
"require": {
15+
"ddebin/atom-generator": "^0.1"
16+
}
17+
}
18+
```
19+
20+
## Example
21+
22+
```php
23+
<?php
24+
25+
include_once 'vendor/autoload.php';
26+
27+
$feed = new AtomGenerator\Feed();
28+
$feed->setTitle('Blog');
29+
$feed->setUpdatedDateTime(new DateTime('now'));
30+
31+
$entry = new AtomGenerator\Entry();
32+
$entry->setTitle('Post', 'text');
33+
$entry->setId('tag:id');
34+
$entry->setContent('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', 'text');
35+
$entry->setUpdatedDateTime(new DateTime('2019-05-04T21:00:40Z'));
36+
37+
$feed->addEntry($entry);
38+
39+
echo $feed->saveXML();
40+
```
41+
42+
## Validation
43+
44+
A validation tool is included with static method `Feed::validate`. It uses a [Relax NG](https://en.wikipedia.org/wiki/RELAX_NG) schema coming from <https://validator.w3.org/feed/docs/rfc4287.html#schema> (inspired by <https://cweiske.de/tagebuch/atom-validation.htm>).

composer.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
},
2222
"require-dev": {
2323
"friendsofphp/php-cs-fixer": "^2.15",
24-
"phpunit/phpunit": "^7"
24+
"phpunit/phpunit": "^7",
25+
"phpstan/phpstan-strict-rules": "^0.11.1",
26+
"phpstan/phpstan-webmozart-assert": "^0.11.2"
2527
},
2628
"config": {
2729
"platform": {
@@ -35,11 +37,12 @@
3537
},
3638
"autoload-dev": {
3739
"psr-4": {
38-
"Tests\\": "tests"
40+
"Tests\\": "tests/"
3941
}
4042
},
4143
"scripts": {
42-
"test": "./vendor/bin/php-cs-fixer fix --allow-risky=yes && ./vendor/bin/phpunit",
44+
"test": "./vendor/bin/php-cs-fixer fix --allow-risky=yes && ./vendor/bin/phpstan analyse -l 7 -c phpstan.neon src tests && ./vendor/bin/phpunit",
45+
"phpstan": "./vendor/bin/phpstan analyse -l 7 -c phpstan.neon src tests",
4346
"phpunit": "./vendor/bin/phpunit"
4447
}
4548
}

0 commit comments

Comments
 (0)