Completed
Push — 5.x ( e82a2b...3cd537 )
by Lars
04:29
created

Swift_Mime_ContentEncoder_RawContentEncoder   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 80%
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 46
ccs 8
cts 10
cp 0.8
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A encodeString() 0 4 1
A encodeByteStream() 0 6 2
A getName() 0 4 1
A charsetChanged() 0 3 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
 * Handles raw Transfer Encoding in Swift Mailer.
13
 *
14
 *
15
 * @author Sebastiaan Stok <[email protected]>
16
 */
17
class Swift_Mime_ContentEncoder_RawContentEncoder implements Swift_Mime_ContentEncoder
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...
18
{
19
    /**
20
     * Encode a given string to produce an encoded string.
21
     *
22
     * @param string $string
23
     * @param int    $firstLineOffset ignored
24
     * @param int    $maxLineLength   ignored
25
     *
26
     * @return string
27
     */
28
    public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
29
    {
30
        return $string;
31
    }
32
33
    /**
34
     * Encode stream $in to stream $out.
35
     *
36
     * @param int                    $firstLineOffset ignored
37
     * @param int                    $maxLineLength   ignored
38
     */
39 8
    public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
40
    {
41 8
        while (false !== ($bytes = $os->read(8192))) {
42 8
            $is->write($bytes);
0 ignored issues
show
Bug introduced by
It seems like $bytes defined by $os->read(8192) on line 41 can also be of type boolean; however, Swift_InputByteStream::write() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
43
        }
44 8
    }
45
46
    /**
47
     * Get the name of this encoding scheme.
48
     *
49
     * @return string
50
     */
51 8
    public function getName()
52
    {
53 8
        return 'raw';
54
    }
55
56
    /**
57
     * Not used.
58
     */
59 8
    public function charsetChanged($charset)
60
    {
61 8
    }
62
}
63