Skip to content

Commit

Permalink
Php 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
josefbenjac committed Jun 18, 2018
1 parent 2049dc6 commit 8778376
Show file tree
Hide file tree
Showing 31 changed files with 113 additions and 224 deletions.
9 changes: 0 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
language: php
php:
- 5.6
- 7.0
- 7.1
- 7.2

Expand All @@ -15,13 +13,6 @@ script:

jobs:
include:
- env: title="Lowest Dependencies 5.6"
php: 5.6
install:
- travis_retry composer update --no-progress --prefer-dist --prefer-lowest
script:
- composer run-script phpunit

- env: title="Lowest Dependencies 7.1"
php: 7.1
install:
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "Configurable library for periodic email sending",
"license": "MIT",
"require": {
"php": ">=7.1",
"contributte/scheduler": "dev-master",
"contributte/mailing": "^0.1.0",
"dragonmantank/cron-expression": "1.2.1",
Expand All @@ -12,7 +13,7 @@
"nette/http": "^2.4"
},
"require-dev": {
"ninjify/qa": "~0.4.0",
"ninjify/qa": "^0.8.0",
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^5.7.25"
},
Expand Down
19 changes: 19 additions & 0 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<ruleset name="Nettrine">
<!-- Contributte Coding Standard -->
<rule ref="./vendor/ninjify/coding-standard/contributte.xml"/>

<!-- Specific -->
<!--<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">-->
<!--<properties>-->
<!--<property name="rootNamespaces" type="array" value="-->
<!--src=>Nettrine\ORM,-->
<!--tests/cases=>Tests\Nettrine\ORM\Cases,-->
<!--tests/fixtures=>Tests\Nettrine\ORM\Fixtures-->
<!--"/>-->
<!--</properties>-->
<!--</rule>-->

<!--Exclude folders -->
<exclude-pattern>/tests/tmp</exclude-pattern>
</ruleset>
11 changes: 3 additions & 8 deletions src/DI/ReportMailingExtension.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Tlapnet\ReportMailing\DI;

Expand Down Expand Up @@ -36,12 +36,7 @@ class ReportMailingExtension extends CompilerExtension
'globalProcessors' => [],
];

/**
* Register services
*
* @return void
*/
public function loadConfiguration()
public function loadConfiguration(): void
{
$builder = $this->getContainerBuilder();
$config = $this->validateConfig($this->defaults);
Expand Down Expand Up @@ -97,7 +92,7 @@ public function loadConfiguration()
}
$cron = $feedConfig['cron'];
// Mail
$mailConfig = new Statement(MailConfig::class, [isset($feedConfig['mail']) ? $feedConfig['mail'] : []]);
$mailConfig = new Statement(MailConfig::class, [$feedConfig['mail'] ?? []]);
// Processors
$processorsConfig = [];
if (isset($feedConfig['processors'])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/Logic/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Tlapnet\ReportMailing\Exceptions\Logic;

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/Logic/InvalidStateException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Tlapnet\ReportMailing\Exceptions\Logic;

Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/LogicException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Tlapnet\ReportMailing\Exceptions;

Expand Down
18 changes: 5 additions & 13 deletions src/Feed.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Tlapnet\ReportMailing;

Expand All @@ -17,37 +17,29 @@ class Feed
private $processors = [];

/**
* @param MailConfig $mailConfig
* @param string $expression
* @param ProcessorConfig[] $processors
*/
public function __construct(MailConfig $mailConfig, $expression, $processors)
public function __construct(MailConfig $mailConfig, string $expression, array $processors)
{
$this->expression = $expression;
$this->mailConfig = $mailConfig;
$this->processors = $processors;
}

/**
* @return string
*/
public function getExpression()
public function getExpression(): string
{
return $this->expression;
}

/**
* @return MailConfig
*/
public function getMailConfig()
public function getMailConfig(): MailConfig
{
return $this->mailConfig;
}

/**
* @return ProcessorConfig[]
*/
public function getProcessors()
public function getProcessors(): array
{
return $this->processors;
}
Expand Down
23 changes: 7 additions & 16 deletions src/JobContainer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Tlapnet\ReportMailing;

Expand All @@ -8,41 +8,32 @@ class JobContainer
/** @var ReportSenderJob[] */
private $jobs = [];

/**
* @param ReportSenderJob $job
* @param string|NULL $key
* @return void
*/
public function add(ReportSenderJob $job, $key = NULL)
public function add(ReportSenderJob $job, ?string $key = null): void
{
if ($key !== NULL) {
if ($key !== null) {
$this->jobs[$key] = $job;
return;
}
$this->jobs[] = $job;
}

/**
* @param string $key
* @return ReportSenderJob|NULL
*/
public function get($key)
public function get(string $key): ?ReportSenderJob
{
return isset($this->jobs[$key]) ? $this->jobs[$key] : NULL;
return $this->jobs[$key] ?? null;
}

/**
* @return ReportSenderJob[]
*/
public function getAll()
public function getAll(): array
{
return $this->jobs;
}

/**
* @return Feed[]
*/
public function getFeeds()
public function getFeeds(): array
{
$feeds = [];
$jobs = $this->getAll();
Expand Down
42 changes: 13 additions & 29 deletions src/MailConfig.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Tlapnet\ReportMailing;

Expand All @@ -23,80 +23,64 @@ class MailConfig
public function __construct(array $config)
{
// string or array
$to = isset($config['to']) ? $config['to'] : [];
$to = $config['to'] ?? [];
if (is_string($to)) {
$to = [$to];
}
$this->to = $to;
$this->subject = isset($config['subject']) ? $config['subject'] : '';
$this->templateFile = isset($config['template']['file']) ? $config['template']['file'] : '';
$this->templateParams = isset($config['template']['params']) ? $config['template']['params'] : [];
$this->subject = $config['subject'] ?? '';
$this->templateFile = $config['template']['file'] ?? '';
$this->templateParams = $config['template']['params'] ?? [];
}

/**
* @return string[]
*/
public function getTo()
public function getTo(): array
{
return $this->to;
}

/**
* @param string[] $to
* @return void
*/
public function setTo($to)
public function setTo(array $to): void
{
$this->to = $to;
}

/**
* @return string
*/
public function getSubject()
public function getSubject(): string
{
return $this->subject;
}

/**
* @param string $subject
* @return void
*/
public function setSubject($subject)
public function setSubject(string $subject): void
{
$this->subject = $subject;
}

/**
* @return string
*/
public function getTemplateFile()
public function getTemplateFile(): string
{
return $this->templateFile;
}

/**
* @param string $templateFile
* @return void
*/
public function setTemplateFile($templateFile)
public function setTemplateFile(string $templateFile): void
{
$this->templateFile = $templateFile;
}

/**
* @return mixed[]
*/
public function getTemplateParams()
public function getTemplateParams(): array
{
return $this->templateParams;
}

/**
* @param mixed[] $templateParams
* @return void
*/
public function setTemplateParams($templateParams)
public function setTemplateParams(array $templateParams): void
{
$this->templateParams = $templateParams;
}
Expand Down
12 changes: 2 additions & 10 deletions src/MessageBuilder.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Tlapnet\ReportMailing;

Expand All @@ -15,10 +15,6 @@ class MessageBuilder
/** @var IMailBuilderFactory */
private $mailBuilderFactory;

/**
* @param ProcessorResolver $processorResolver
* @param IMailBuilderFactory $mailBuilderFactory
*/
public function __construct(
ProcessorResolver $processorResolver,
IMailBuilderFactory $mailBuilderFactory
Expand All @@ -28,11 +24,7 @@ public function __construct(
$this->mailBuilderFactory = $mailBuilderFactory;
}

/**
* @param Feed $feed
* @return MailBuilder
*/
public function create(Feed $feed)
public function create(Feed $feed): MailBuilder
{
$config = $feed->getMailConfig();
$message = $this->mailBuilderFactory->create();
Expand Down
8 changes: 3 additions & 5 deletions src/Processor/FromProcessor.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Tlapnet\ReportMailing\Processor;

Expand All @@ -8,13 +8,11 @@ class FromProcessor implements IProcessor
{

/**
* @param MailBuilder $message
* @param mixed[] $meta
* @return MailBuilder
*/
public function processMessage(MailBuilder $message, $meta)
public function processMessage(MailBuilder $message, array $meta): MailBuilder
{
$message->setFrom($meta['mail'], isset($meta['name']) ? $meta['name'] : '');
$message->setFrom($meta['mail'], $meta['name'] ?? '');
return $message;
}

Expand Down
6 changes: 2 additions & 4 deletions src/Processor/IProcessor.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);

namespace Tlapnet\ReportMailing\Processor;

Expand All @@ -8,10 +8,8 @@ interface IProcessor
{

/**
* @param MailBuilder $message
* @param mixed[] $meta
* @return MailBuilder
*/
public function processMessage(MailBuilder $message, $meta);
public function processMessage(MailBuilder $message, array $meta): MailBuilder;

}
Loading

0 comments on commit 8778376

Please sign in to comment.