GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 735e98...9e3fb1 )
by Pavel
02:30
created

src/MailFactory.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
 * @copyright   Copyright (c) 2015 ublaboo <[email protected]>
5
 * @author      Pavel Janda <[email protected]nda.com>
6
 * @package     Ublaboo
7
 */
8
9
namespace Ublaboo\Mailing;
10
11
use Nette;
12
use Nette\Mail\Message;
13
use Ublaboo;
14
15
class MailFactory extends Nette\Object
16
{
17
18
	/**
19
	 * @var string
20
	 */
21
	private $config;
22
23
	/**
24
	 * @var Nette\Mail\IMailer
25
	 */
26
	private $mailer;
27
28
	/**
29
	 * @var Message
30
	 */
31
	private $message;
32
33
	/**
34
	 * @var array
35
	 */
36
	private $mails;
37
38
	/**
39
	 * @var Nette\Application\UI\ITemplateFactory
40
	 */
41
	private $templateFactory;
42
43
	/**
44
	 * @var Nette\Application\LinkGenerator
45
	 */
46
	private $linkGenerator;
47
48
	/**
49
	 * @var ILogger
50
	 */
51
	private $logger;
52
53
	/**
54
	 * @var string
55
	 */
56
	private $mail_images_base_path;
57
58
59
	public function __construct(
60
		$config,
61
		$mail_images_base_path,
62
		$mails,
63
		Nette\Mail\IMailer $mailer,
64
		Nette\Application\LinkGenerator $linkGenerator,
65
		Nette\Application\UI\ITemplateFactory $templateFactory,
66
		ILogger $logger
67
	) {
68
		$this->config = $config;
69
		$this->mailer = $mailer;
70
		$this->mails  = $mails;
71
		$this->linkGenerator = $linkGenerator;
72
		$this->templateFactory = $templateFactory;
73
		$this->logger = $logger;
74
	}
75
76
77
	/**
78
	 * Create email by given type
79
	 * @param  string $type
80
	 * @return Ublaboo\Mailing\Mail
81
	 * @throws MailCreationException
82
	 */
83
	public function createByType($type, $args)
84
	{
85
		$this->message = new Message;
86
87
		if (class_exists($type)) {
88
			$mail = new $type(
89
				$this->config,
90
				$this->mails,
91
				$this->mailer,
92
				$this->message,
93
				$this->linkGenerator,
94
				$this->templateFactory,
95
				$this->logger,
96
				$args
97
			);
98
99
			$mail->setBasePath($this->mail_images_base_path);
100
101
			return $mail;
102
		}
103
104
		throw new MailCreationException("Email [$type] does not exist");
105
	}
106
107
}
108
109
110
class MailCreationException extends \Exception
0 ignored issues
show
Coding Style Compatibility introduced by Pavel Janda
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
111
{
112
}
113