Passed
Push — master ( 1f914d...5ffc4b )
by Aimeos
12:32
created

Symfony::send()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2023
6
 * @package MW
7
 * @subpackage Session
8
 */
9
10
11
namespace Aimeos\Base\Mail;
12
13
14
/**
15
 * Implementation using Symfony sessions.
16
 *
17
 * @package MW
18
 * @subpackage Session
19
 */
20
class Symfony extends Base implements \Aimeos\Base\Mail\Iface
0 ignored issues
show
Bug introduced by
The type Aimeos\Base\Mail\Base was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
{
22
	private \Closure $closure;
23
24
	/**
25
	 * Initializes the instance of the class.
26
	 *
27
	 * @param \Closure $closure Closure generating TYPO3 mail message objects
28
	 */
29
	public function __construct( \Closure $closure )
30
	{
31
		$this->closure = $closure;
32
	}
33
34
35
	/**
36
	 * Creates a new e-mail message object.
37
	 *
38
	 * @param string $charset Default charset of the message
39
	 * @return \Aimeos\Base\Mail\Message\Iface E-mail message object
40
	 */
41
	public function create( string $charset = 'UTF-8' ) : \Aimeos\Base\Mail\Message\Iface
42
	{
43
		$closure = $this->closure;
44
		return new \Aimeos\Base\Mail\Message\Symfony( $closure(), new \Symfony\Component\Mime\Email(), $charset );
45
	}
46
47
48
	/**
49
	 * Sends the e-mail message to the mail server.
50
	 *
51
	 * @param \Aimeos\Base\Mail\Message\Iface $message E-mail message object
52
	 */
53
	public function send( \Aimeos\Base\Mail\Message\Iface $message ) : Iface
54
	{
55
		$closure = $this->closure;
56
		$closure()->send( $message->object() );
0 ignored issues
show
Bug introduced by
The method object() does not exist on Aimeos\Base\Mail\Message\Iface. It seems like you code against a sub-type of Aimeos\Base\Mail\Message\Iface such as Aimeos\Base\Mail\Message\Symfony. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

56
		$closure()->send( $message->/** @scrutinizer ignore-call */ object() );
Loading history...
57
58
		return $this;
59
	}
60
}
61