Completed
Push — master ( 62f4cb...329d4d )
by Rudie
02:07
created
src/IMAPMailbox.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
 	protected $imap; // rdx\imap\IMAPTransport
17 17
 
18
-	public function __construct( $server, $username, $password, $mailbox = null, array $flags = [] ) {
18
+	public function __construct($server, $username, $password, $mailbox = null, array $flags = []) {
19 19
 		$this->server = $server;
20 20
 		$this->username = $username;
21 21
 		$this->password = $password;
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	}
27 27
 
28 28
 	public function connect() {
29
-		if ( !$this->imap ) {
29
+		if (!$this->imap) {
30 30
 			$this->imap = $this->createTransport()->open(
31 31
 				$this->server,
32 32
 				$this->username,
@@ -47,29 +47,29 @@  discard block
 block discarded – undo
47 47
 		return new IMAPTransport;
48 48
 	}
49 49
 
50
-	public function createMessage( $msgNum, $unseen = null ) {
50
+	public function createMessage($msgNum, $unseen = null) {
51 51
 		return new IMAPMessage($this, $msgNum, $unseen);
52 52
 	}
53 53
 
54
-	public function headers( $newestFirst = true ) {
54
+	public function headers($newestFirst = true) {
55 55
 		$this->connect();
56 56
 
57 57
 		$headers = $this->imap()->headers();
58 58
 
59
-		if ( $newestFirst ) {
59
+		if ($newestFirst) {
60 60
 			$headers = array_reverse($headers);
61 61
 		}
62 62
 
63 63
 		return $headers;
64 64
 	}
65 65
 
66
-	public function message( $msgNum ) {
66
+	public function message($msgNum) {
67 67
 		$this->connect();
68 68
 
69 69
 		return $this->createMessage($msgNum);
70 70
 	}
71 71
 
72
-	public function messages( array $options = [] ) {
72
+	public function messages(array $options = []) {
73 73
 		$options += [
74 74
 			'offset' => 0,
75 75
 			'limit' => 0,
@@ -81,21 +81,21 @@  discard block
 block discarded – undo
81 81
 
82 82
 		$messages = [];
83 83
 		$eligibles = 0;
84
-		foreach ( $headers AS $n => $header ) {
85
-			if ( preg_match('/([UN]?)\s+(\d+)\)/', $header, $match) ) {
86
-				$unseen = (bool) trim($match[1]);
87
-				$msgNum = (int) $match[2];
84
+		foreach ($headers AS $n => $header) {
85
+			if (preg_match('/([UN]?)\s+(\d+)\)/', $header, $match)) {
86
+				$unseen = (bool)trim($match[1]);
87
+				$msgNum = (int)$match[2];
88 88
 
89 89
 				$eligible = $options['seen'] === null || $unseen != $options['seen'];
90
-				if ( $eligible ) {
90
+				if ($eligible) {
91 91
 					$eligibles++;
92 92
 
93
-					if ( $eligibles > $options['offset'] ) {
93
+					if ($eligibles > $options['offset']) {
94 94
 						$messages[] = $this->createMessage($msgNum, $unseen);
95 95
 					}
96 96
 				}
97 97
 
98
-				if ( $options['limit'] && isset($messages[$options['limit']-1]) ) {
98
+				if ($options['limit'] && isset($messages[$options['limit']-1])) {
99 99
 					break;
100 100
 				}
101 101
 			}
Please login to merge, or discard this patch.
src/IMAPMessagePartInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@
 block discarded – undo
7 7
 	public function structure();
8 8
 	public function parts();
9 9
 	public function allParts();
10
-	public function part( $index );
10
+	public function part($index);
11 11
 	public function content();
12 12
 	public function parameters();
13
-	public function parameter( $name );
13
+	public function parameter($name);
14 14
 
15 15
 	// public function attachments();
16 16
 	// public function allAttachments();
Please login to merge, or discard this patch.
src/IMAPMessageContent.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,8 +52,7 @@
 block discarded – undo
52 52
 					}
53 53
 
54 54
 					$iterate($part);
55
-				}
56
-				else {
55
+				} else {
57 56
 					$parts[] = $part;
58 57
 				}
59 58
 			}
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@  discard block
 block discarded – undo
8 8
 	protected $parts = []; // Array<rdx\imap\IMAPMessagePart>
9 9
 	protected $parameters = [];
10 10
 
11
-	public function allParts( $withContainers = false ) {
11
+	public function allParts($withContainers = false) {
12 12
 		$parts = [];
13 13
 		$iterate = function($message) use (&$iterate, &$parts, $withContainers) {
14
-			foreach ( $message->parts() as $part ) {
15
-				if ( $part->parts() ) {
16
-					if ( $withContainers ) {
14
+			foreach ($message->parts() as $part) {
15
+				if ($part->parts()) {
16
+					if ($withContainers) {
17 17
 						$parts[] = $part;
18 18
 					}
19 19
 
@@ -29,57 +29,57 @@  discard block
 block discarded – undo
29 29
 		return $parts;
30 30
 	}
31 31
 
32
-	public function part( $index ) {
32
+	public function part($index) {
33 33
 		$parts = $this->parts();
34 34
 		return @$parts[$index];
35 35
 	}
36 36
 
37 37
 	public function parameters() {
38
-		if ( empty($this->parameters) ) {
38
+		if (empty($this->parameters)) {
39 39
 			$structure = $this->structure();
40 40
 
41 41
 			$this->parameters['bytes'] = @$structure->bytes;
42 42
 
43
-			foreach ((array) @$structure->parameters as $param) {
44
-				$this->parameters[ strtolower($param->attribute) ] = $param->value;
43
+			foreach ((array)@$structure->parameters as $param) {
44
+				$this->parameters[strtolower($param->attribute)] = $param->value;
45 45
 			}
46
-			foreach ((array) @$structure->dparameters as $param) {
47
-				$this->parameters[ strtolower($param->attribute) ] = $param->value;
46
+			foreach ((array)@$structure->dparameters as $param) {
47
+				$this->parameters[strtolower($param->attribute)] = $param->value;
48 48
 			}
49 49
 		}
50 50
 
51 51
 		return $this->parameters;
52 52
 	}
53 53
 
54
-	public function parameter( $name ) {
54
+	public function parameter($name) {
55 55
 		$parameters = $this->parameters();
56
-		return @$parameters[ strtolower($name) ];
56
+		return @$parameters[strtolower($name)];
57 57
 	}
58 58
 
59
-	public function subtypePart( $subtypes, $recursive ) {
60
-		$subtypes = (array) $subtypes;
59
+	public function subtypePart($subtypes, $recursive) {
60
+		$subtypes = (array)$subtypes;
61 61
 		$method = [$this, $recursive ? 'allParts' : 'parts'];
62 62
 		$parts = call_user_func($method);
63 63
 		array_unshift($parts, $this);
64 64
 
65
-		foreach ( $parts as $part ) {
66
-			if ( in_array($part->subtype(), $subtypes) ) {
65
+		foreach ($parts as $part) {
66
+			if (in_array($part->subtype(), $subtypes)) {
67 67
 				return $part;
68 68
 			}
69 69
 		}
70 70
 	}
71 71
 
72
-	public function subtypeContent( $subtypes, $recursive ) {
73
-		if ( $part = $this->subtypePart($subtypes, $recursive) ) {
72
+	public function subtypeContent($subtypes, $recursive) {
73
+		if ($part = $this->subtypePart($subtypes, $recursive)) {
74 74
 			return $part->content();
75 75
 		}
76 76
 	}
77 77
 
78
-	public function text( $recursive = false ) {
78
+	public function text($recursive = false) {
79 79
 		return $this->subtypeContent($this->mailbox()->getTextSubtypes(), $recursive);
80 80
 	}
81 81
 
82
-	public function html( $recursive = false ) {
82
+	public function html($recursive = false) {
83 83
 		return $this->subtypeContent($this->mailbox()->getHtmlSubtypes(), $recursive);
84 84
 	}
85 85
 
Please login to merge, or discard this patch.
src/IMAPMessage.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -103,8 +103,7 @@
 block discarded – undo
103 103
 					$structure,
104 104
 					[1]
105 105
 				);
106
-			}
107
-			else {
106
+			} else {
108 107
 				foreach ($structure->parts as $n => $part) {
109 108
 					$this->parts[] = $this->createMessagePart(
110 109
 						$part,
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -17,33 +17,33 @@  discard block
 block discarded – undo
17 17
 	protected $subject = '';
18 18
 	protected $subtype = '';
19 19
 
20
-	public function __construct( IMAPMailbox $mailbox, $msgNumber, $unseen = null ) {
20
+	public function __construct(IMAPMailbox $mailbox, $msgNumber, $unseen = null) {
21 21
 		$this->mailbox = $mailbox;
22 22
 		$this->msgNumber = $msgNumber;
23 23
 		$this->unseen = $unseen;
24 24
 
25
-		if ( $unseen === null ) {
26
-			$this->unseen = (bool) trim($this->header('unseen'));
25
+		if ($unseen === null) {
26
+			$this->unseen = (bool)trim($this->header('unseen'));
27 27
 		}
28 28
 	}
29 29
 
30
-	protected function flags( $flags, $clear ) {
30
+	protected function flags($flags, $clear) {
31 31
 		$cb = [$this->mailbox()->imap(), $clear ? 'unflag' : 'flag'];
32 32
 
33 33
 		$feedback = [];
34
-		foreach ( (array)$flags AS $flag ) {
35
-			$flag = '\\' . ucfirst($flag);
34
+		foreach ((array)$flags AS $flag) {
35
+			$flag = '\\'.ucfirst($flag);
36 36
 			$feedback[] = call_user_func($cb, $this->msgNumber, $flag);
37 37
 		}
38 38
 
39 39
 		return is_array($flags) ? $feedback : $feedback[0];
40 40
 	}
41 41
 
42
-	public function flag( $flags ) {
42
+	public function flag($flags) {
43 43
 		return $this->flags($flags, false);
44 44
 	}
45 45
 
46
-	public function unflag( $flags ) {
46
+	public function unflag($flags) {
47 47
 		return $this->flags($flags, true);
48 48
 	}
49 49
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	}
53 53
 
54 54
 	public function subject() {
55
-		if ( empty($this->subject) ) {
55
+		if (empty($this->subject)) {
56 56
 			$subject = $this->mailbox()->imap()->utf8($this->header('subject'));
57 57
 			$this->subject = trim($subject);
58 58
 		}
@@ -61,24 +61,24 @@  discard block
 block discarded – undo
61 61
 	}
62 62
 
63 63
 	public function headers() {
64
-		if ( empty($this->headers) ) {
64
+		if (empty($this->headers)) {
65 65
 			$this->headers = $this->mailbox()->imap()->headerinfo($this->msgNumber);
66 66
 		}
67 67
 
68 68
 		return $this->headers;
69 69
 	}
70 70
 
71
-	public function header( $name ) {
71
+	public function header($name) {
72 72
 		$headers = $this->headers();
73
-		return @$headers[ strtolower($name) ];
73
+		return @$headers[strtolower($name)];
74 74
 	}
75 75
 
76
-	public function createMessagePart( $structure, $section ) {
76
+	public function createMessagePart($structure, $section) {
77 77
 		return new IMAPMessagePart($this, $structure, $section);
78 78
 	}
79 79
 
80 80
 	public function parts() {
81
-		if ( empty($this->parts) ) {
81
+		if (empty($this->parts)) {
82 82
 			$structure = $this->structure();
83 83
 
84 84
 			// Possibilities:
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 			// - CALENDAR
93 93
 			// - JPEG
94 94
 
95
-			if ( empty($structure->parts) ) {
95
+			if (empty($structure->parts)) {
96 96
 				$this->parts[] = $this->createMessagePart(
97 97
 					$structure,
98 98
 					[1]
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	}
113 113
 
114 114
 	public function structure() {
115
-		if ( empty($this->structure) ) {
115
+		if (empty($this->structure)) {
116 116
 			$this->structure = $this->mailbox()->imap()->fetchstructure($this->msgNumber);
117 117
 		}
118 118
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	}
121 121
 
122 122
 	public function subtype() {
123
-		if ( empty($this->subtype) ) {
123
+		if (empty($this->subtype)) {
124 124
 			$structure = $this->structure();
125 125
 			$this->subtype = @$structure->subtype ?: '';
126 126
 		}
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	}
134 134
 
135 135
 	public function content() {
136
-		if ( count($this->parts()) == 1 ) {
136
+		if (count($this->parts()) == 1) {
137 137
 			return $this->part(0)->content();
138 138
 		}
139 139
 
@@ -146,16 +146,16 @@  discard block
 block discarded – undo
146 146
 
147 147
 	public function simpleStructure() {
148 148
 		$parts = [];
149
-		foreach ( $this->allParts(true) as $part ) {
149
+		foreach ($this->allParts(true) as $part) {
150 150
 			$name = '';
151 151
 
152
-			$name .= implode('.', $part->section()) . '. ';
153
-			if ( $part->parts() ) {
152
+			$name .= implode('.', $part->section()).'. ';
153
+			if ($part->parts()) {
154 154
 				$name .= '*';
155 155
 			}
156 156
 			$name .= $part->subtype();
157
-			if ( $bytes = $part->parameter('bytes') ) {
158
-				$name .= ' (' . $bytes . ')';
157
+			if ($bytes = $part->parameter('bytes')) {
158
+				$name .= ' ('.$bytes.')';
159 159
 			}
160 160
 
161 161
 			$parts[] = $name;
Please login to merge, or discard this patch.
src/IMAPTransport.php 2 patches
Doc Comments   +19 added lines patch added patch discarded remove patch
@@ -9,6 +9,12 @@  discard block
 block discarded – undo
9 9
 
10 10
 	protected $resource; // imap_open() resource
11 11
 
12
+	/**
13
+	 * @param string $server
14
+	 * @param string $username
15
+	 * @param string $password
16
+	 * @param string $mailbox
17
+	 */
12 18
 	public function open( $server, $username, $password, $mailbox, array $flags ) {
13 19
 		if ( !empty($flags) ) {
14 20
 			$server .= '/' . implode('/', $flags);
@@ -34,6 +40,9 @@  discard block
 block discarded – undo
34 40
 		return imap_utf8($string);
35 41
 	}
36 42
 
43
+	/**
44
+	 * @param integer $msgNumber
45
+	 */
37 46
 	public function headerinfo( $msgNumber ) {
38 47
 		return $this->iteratorToLowercaseArray(imap_headerinfo($this->resource, $msgNumber));
39 48
 	}
@@ -46,10 +55,17 @@  discard block
 block discarded – undo
46 55
 		return imap_setflag_full($this->resource, $msgNumber, $flag);
47 56
 	}
48 57
 
58
+	/**
59
+	 * @param integer $msgNumber
60
+	 */
49 61
 	public function fetchstructure( $msgNumber ) {
50 62
 		return imap_fetchstructure($this->resource, $msgNumber);
51 63
 	}
52 64
 
65
+	/**
66
+	 * @param integer $msgNumber
67
+	 * @param string $section
68
+	 */
53 69
 	public function fetchbody( $msgNumber, $section ) {
54 70
 		return quoted_printable_decode(imap_fetchbody($this->resource, $msgNumber, $section, FT_PEEK));
55 71
 	}
@@ -58,6 +74,9 @@  discard block
 block discarded – undo
58 74
 		return imap_expunge($this->resource);
59 75
 	}
60 76
 
77
+	/**
78
+	 * @param integer $msgNumber
79
+	 */
61 80
 	public function delete( $msgNumber ) {
62 81
 		return imap_delete($this->resource, $msgNumber);
63 82
 	}
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -9,14 +9,14 @@  discard block
 block discarded – undo
9 9
 
10 10
 	protected $resource; // imap_open() resource
11 11
 
12
-	public function open( $server, $username, $password, $mailbox, array $flags ) {
13
-		if ( !empty($flags) ) {
14
-			$server .= '/' . implode('/', $flags);
12
+	public function open($server, $username, $password, $mailbox, array $flags) {
13
+		if (!empty($flags)) {
14
+			$server .= '/'.implode('/', $flags);
15 15
 		}
16 16
 
17
-		$mailbox = '{' . $server . '}' . $mailbox;
17
+		$mailbox = '{'.$server.'}'.$mailbox;
18 18
 		$this->resource = @imap_open($mailbox, $username, $password);
19
-		if ( !$this->resource ) {
19
+		if (!$this->resource) {
20 20
 			$error = imap_last_error();
21 21
 			imap_errors();
22 22
 			imap_alerts();
@@ -30,27 +30,27 @@  discard block
 block discarded – undo
30 30
 		return imap_headers($this->resource);
31 31
 	}
32 32
 
33
-	public function utf8( $string ) {
33
+	public function utf8($string) {
34 34
 		return imap_utf8($string);
35 35
 	}
36 36
 
37
-	public function headerinfo( $msgNumber ) {
37
+	public function headerinfo($msgNumber) {
38 38
 		return $this->iteratorToLowercaseArray(imap_headerinfo($this->resource, $msgNumber));
39 39
 	}
40 40
 
41
-	public function unflag( $msgNumber, $flag ) {
41
+	public function unflag($msgNumber, $flag) {
42 42
 		return imap_clearflag_full($this->resource, $msgNumber, $flag);
43 43
 	}
44 44
 
45
-	public function flag( $msgNumber, $flag ) {
45
+	public function flag($msgNumber, $flag) {
46 46
 		return imap_setflag_full($this->resource, $msgNumber, $flag);
47 47
 	}
48 48
 
49
-	public function fetchstructure( $msgNumber ) {
49
+	public function fetchstructure($msgNumber) {
50 50
 		return imap_fetchstructure($this->resource, $msgNumber);
51 51
 	}
52 52
 
53
-	public function fetchbody( $msgNumber, $section ) {
53
+	public function fetchbody($msgNumber, $section) {
54 54
 		return quoted_printable_decode(imap_fetchbody($this->resource, $msgNumber, $section, FT_PEEK));
55 55
 	}
56 56
 
@@ -58,18 +58,18 @@  discard block
 block discarded – undo
58 58
 		return imap_expunge($this->resource);
59 59
 	}
60 60
 
61
-	public function delete( $msgNumber ) {
61
+	public function delete($msgNumber) {
62 62
 		return imap_delete($this->resource, $msgNumber);
63 63
 	}
64 64
 
65 65
 	public function mailboxmsginfo() {
66
-		return (object) $this->iteratorToLowercaseArray(imap_mailboxmsginfo($this->resource));
66
+		return (object)$this->iteratorToLowercaseArray(imap_mailboxmsginfo($this->resource));
67 67
 	}
68 68
 
69
-	protected function iteratorToLowercaseArray( $iterator ) {
69
+	protected function iteratorToLowercaseArray($iterator) {
70 70
 		$data = [];
71
-		foreach ( $iterator as $name => $value ) {
72
-			$data[ strtolower($name) ] = $value;
71
+		foreach ($iterator as $name => $value) {
72
+			$data[strtolower($name)] = $value;
73 73
 		}
74 74
 
75 75
 		return $data;
Please login to merge, or discard this patch.
src/IMAPTransportInterface.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 interface IMAPTransportInterface {
6 6
 
7 7
 	/**
8
-	 * @return rdx\imap\IMAPTransportInterface
8
+	 * @return IMAPTransport
9 9
 	 */
10 10
 	public function open( $server, $username, $password, $mailbox, array $flags );
11 11
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 	/**
8 8
 	 * @return rdx\imap\IMAPTransportInterface
9 9
 	 */
10
-	public function open( $server, $username, $password, $mailbox, array $flags );
10
+	public function open($server, $username, $password, $mailbox, array $flags);
11 11
 
12 12
 	/**
13 13
 	 * @return array<string>
@@ -17,32 +17,32 @@  discard block
 block discarded – undo
17 17
 	/**
18 18
 	 * @return string
19 19
 	 */
20
-	public function utf8( $string );
20
+	public function utf8($string);
21 21
 
22 22
 	/**
23 23
 	 * @return array<mixed>
24 24
 	 */
25
-	public function headerinfo( $msgNumber );
25
+	public function headerinfo($msgNumber);
26 26
 
27 27
 	/**
28 28
 	 * @return bool
29 29
 	 */
30
-	public function unflag( $msgNumber, $flag );
30
+	public function unflag($msgNumber, $flag);
31 31
 
32 32
 	/**
33 33
 	 * @return bool
34 34
 	 */
35
-	public function flag( $msgNumber, $flag );
35
+	public function flag($msgNumber, $flag);
36 36
 
37 37
 	/**
38 38
 	 * @return object<mixed>
39 39
 	 */
40
-	public function fetchstructure( $msgNumber );
40
+	public function fetchstructure($msgNumber);
41 41
 
42 42
 	/**
43 43
 	 * @return string
44 44
 	 */
45
-	public function fetchbody( $msgNumber, $section );
45
+	public function fetchbody($msgNumber, $section);
46 46
 
47 47
 	/**
48 48
 	 * @return bool
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	/**
53 53
 	 * @return bool
54 54
 	 */
55
-	public function delete( $msgNumber );
55
+	public function delete($msgNumber);
56 56
 
57 57
 	/**
58 58
 	 * @return object
Please login to merge, or discard this patch.
src/IMAPMessagePart.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	protected $message; // rdx\imap\IMAPMessage
14 14
 	protected $skippedParts = []; // Array<stdClass>
15 15
 
16
-	public function __construct( IMAPMessage $message, $structure, array $section ) {
16
+	public function __construct(IMAPMessage $message, $structure, array $section) {
17 17
 		$this->message = $message;
18 18
 		$this->structure = $structure;
19 19
 		$this->section = $section;
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 	}
24 24
 
25 25
 	public function parts() {
26
-		if ( empty($this->parts) && !empty($this->structure()->parts) ) {
26
+		if (empty($this->parts) && !empty($this->structure()->parts)) {
27 27
 			$parts = $this->structure()->parts;
28
-			while ( count($parts) == 1 && empty($parts[0]->bytes) && !empty($parts[0]->parts) ) {
28
+			while (count($parts) == 1 && empty($parts[0]->bytes) && !empty($parts[0]->parts)) {
29 29
 				$this->skippedParts[] = $parts[0];
30 30
 				$parts = $parts[0]->parts;
31 31
 			}
32 32
 
33
-			foreach ( $parts as $n => $part ) {
33
+			foreach ($parts as $n => $part) {
34 34
 				$this->parts[] = $this->message()->createMessagePart(
35 35
 					$part,
36 36
 					array_merge($this->section(), [$n+1])
Please login to merge, or discard this patch.