Swift_Image::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 3
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of SwiftMailer.
5
 * (c) 2004-2009 Chris Corbyn
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
/**
12
 * An image, embedded in a multipart message.
13
 *
14
 * @author Chris Corbyn
15
 */
16
class Swift_Image extends Swift_EmbeddedFile
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
17
{
18
    /**
19
     * Create a new EmbeddedFile.
20
     *
21
     * Details may be optionally provided to the constructor.
22
     *
23
     * @param string|Swift_OutputByteStream $data
24
     * @param string                        $filename
25
     * @param string                        $contentType
26
     */
27 4
    public function __construct($data = null, $filename = null, $contentType = null)
28
    {
29 4
        parent::__construct($data, $filename, $contentType);
30 4
    }
31
32
    /**
33
     * Create a new Image.
34
     *
35
     * @param string|Swift_OutputByteStream $data
36
     * @param string                        $filename
37
     * @param string                        $contentType
38
     *
39
     * @return self
40
     */
41 1
    public static function newInstance($data = null, $filename = null, $contentType = null)
42
    {
43 1
        return new self($data, $filename, $contentType);
44
    }
45
46
    /**
47
     * Create a new Image from a filesystem path.
48
     *
49
     * @param string $path
50
     *
51
     * @return self
52
     */
53 1
    public static function fromPath($path)
54
    {
55 1
        $image = self::newInstance()->setFile(
56 1
            new Swift_ByteStream_FileByteStream($path)
57 1
        );
58
59 1
        return $image;
60
    }
61
}
62