Completed
Push — master ( c1617c...820ca9 )
by Rudie
02:11
created
src/IMAPMessagePart.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -104,6 +104,9 @@
 block discarded – undo
104 104
 		return $this->decode($body);
105 105
 	}
106 106
 
107
+	/**
108
+	 * @param string $content
109
+	 */
107 110
 	public function decode( $content ) {
108 111
 		return quoted_printable_decode($content);
109 112
 	}
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	protected $structure; // typeof stdClass
18 18
 	protected $skippedParts = []; // Array<stdClass>
19 19
 
20
-	public function __construct( IMAPMessage $message, $structure, array $section ) {
20
+	public function __construct(IMAPMessage $message, $structure, array $section) {
21 21
 		$this->message = $message;
22 22
 		$this->structure = $structure;
23 23
 		$this->section = $section;
@@ -27,15 +27,15 @@  discard block
 block discarded – undo
27 27
 	}
28 28
 
29 29
 	public function parts() {
30
-		if ( !empty($this->structure->parts) ) {
30
+		if (!empty($this->structure->parts)) {
31 31
 			$parts = $this->structure->parts;
32 32
 
33
-			while ( count($parts) == 1 && empty($parts[0]->bytes) && !empty($parts[0]->parts) ) {
33
+			while (count($parts) == 1 && empty($parts[0]->bytes) && !empty($parts[0]->parts)) {
34 34
 				$this->skippedParts[] = $parts[0];
35 35
 				$parts = $parts[0]->parts;
36 36
 			}
37 37
 
38
-			foreach ( $parts as $n => $part ) {
38
+			foreach ($parts as $n => $part) {
39 39
 				$this->parts[] = $this->message()->createMessagePart(
40 40
 					$part,
41 41
 					array_merge($this->section(), [$n+1])
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
 		}
45 45
 	}
46 46
 
47
-	public function allParts( $withContainers = false ) {
47
+	public function allParts($withContainers = false) {
48 48
 		$parts = [];
49 49
 		$iterate = function($message) use (&$iterate, &$parts, $withContainers) {
50
-			foreach ( $message->parts() as $part ) {
51
-				if ( $part->parts() ) {
52
-					if ( $withContainers ) {
50
+			foreach ($message->parts() as $part) {
51
+				if ($part->parts()) {
52
+					if ($withContainers) {
53 53
 						$parts[] = $part;
54 54
 					}
55 55
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 		return $parts;
66 66
 	}
67 67
 
68
-	public function part( $index ) {
68
+	public function part($index) {
69 69
 		$parts = $this->parts();
70 70
 		return @$parts[$index];
71 71
 	}
@@ -75,25 +75,25 @@  discard block
 block discarded – undo
75 75
 	}
76 76
 
77 77
 	public function parameters() {
78
-		if ( empty($this->parameters) ) {
78
+		if (empty($this->parameters)) {
79 79
 			$structure = $this->structure();
80 80
 
81 81
 			$this->parameters['bytes'] = @$structure->bytes;
82 82
 
83
-			foreach ((array) @$structure->parameters as $param) {
84
-				$this->parameters[ strtolower($param->attribute) ] = $param->value;
83
+			foreach ((array)@$structure->parameters as $param) {
84
+				$this->parameters[strtolower($param->attribute)] = $param->value;
85 85
 			}
86
-			foreach ((array) @$structure->dparameters as $param) {
87
-				$this->parameters[ strtolower($param->attribute) ] = $param->value;
86
+			foreach ((array)@$structure->dparameters as $param) {
87
+				$this->parameters[strtolower($param->attribute)] = $param->value;
88 88
 			}
89 89
 		}
90 90
 
91 91
 		return $this->parameters;
92 92
 	}
93 93
 
94
-	public function parameter( $name ) {
94
+	public function parameter($name) {
95 95
 		$parameters = $this->parameters();
96
-		return @$parameters[ strtolower($name) ];
96
+		return @$parameters[strtolower($name)];
97 97
 	}
98 98
 
99 99
 	public function content() {
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 		return $this->decode($body);
105 105
 	}
106 106
 
107
-	public function decode( $content ) {
107
+	public function decode($content) {
108 108
 		return quoted_printable_decode($content);
109 109
 	}
110 110
 
Please login to merge, or discard this patch.
src/IMAPMessage.php 2 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -32,6 +32,9 @@  discard block
 block discarded – undo
32 32
 		}
33 33
 	}
34 34
 
35
+	/**
36
+	 * @param boolean $clear
37
+	 */
35 38
 	protected function flags( $flags, $clear ) {
36 39
 		$cb = [$this->imap(), $clear ? 'clearflag' : 'setflag'];
37 40
 
@@ -76,6 +79,9 @@  discard block
 block discarded – undo
76 79
 		return $this->headers;
77 80
 	}
78 81
 
82
+	/**
83
+	 * @param string $name
84
+	 */
79 85
 	public function header( $name ) {
80 86
 		$headers = $this->headers();
81 87
 		return @$headers[ strtolower($name) ];
@@ -140,6 +146,9 @@  discard block
 block discarded – undo
140 146
 		return $parts;
141 147
 	}
142 148
 
149
+	/**
150
+	 * @param integer $index
151
+	 */
143 152
 	public function part( $index ) {
144 153
 		$parts = $this->parts();
145 154
 		return @$parts[$index];
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -22,33 +22,33 @@  discard block
 block discarded – undo
22 22
 	protected $HTMLBody;
23 23
 	protected $attachments = []; // typeof Array<IMAPMessageAttachment>
24 24
 
25
-	public function __construct( IMAPMailbox $mailbox, $msgNumber, $unseen = null ) {
25
+	public function __construct(IMAPMailbox $mailbox, $msgNumber, $unseen = null) {
26 26
 		$this->mailbox = $mailbox;
27 27
 		$this->msgNumber = $msgNumber;
28 28
 		$this->unseen = $unseen;
29 29
 
30
-		if ( $unseen === null ) {
31
-			$this->unseen = (bool) trim($this->header('unseen'));
30
+		if ($unseen === null) {
31
+			$this->unseen = (bool)trim($this->header('unseen'));
32 32
 		}
33 33
 	}
34 34
 
35
-	protected function flags( $flags, $clear ) {
35
+	protected function flags($flags, $clear) {
36 36
 		$cb = [$this->imap(), $clear ? 'clearflag' : 'setflag'];
37 37
 
38 38
 		$feedback = [];
39
-		foreach ( (array)$flags AS $flag ) {
40
-			$flag = '\\' . ucfirst($flag);
39
+		foreach ((array)$flags AS $flag) {
40
+			$flag = '\\'.ucfirst($flag);
41 41
 			$feedback[] = call_user_func($cb, $this->msgNumber, $flag);
42 42
 		}
43 43
 
44 44
 		return is_array($flags) ? $feedback : $feedback[0];
45 45
 	}
46 46
 
47
-	public function flag( $flags ) {
47
+	public function flag($flags) {
48 48
 		return $this->flags($flags, false);
49 49
 	}
50 50
 
51
-	public function unflag( $flags ) {
51
+	public function unflag($flags) {
52 52
 		return $this->flags($flags, true);
53 53
 	}
54 54
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	}
58 58
 
59 59
 	public function subject() {
60
-		if ( empty($this->subject) ) {
60
+		if (empty($this->subject)) {
61 61
 			$subject = $this->mailbox()->imap()->utf8($this->header('subject'));
62 62
 			$this->subject = trim($subject);
63 63
 		}
@@ -66,27 +66,27 @@  discard block
 block discarded – undo
66 66
 	}
67 67
 
68 68
 	public function headers() {
69
-		if ( empty($this->headers) ) {
69
+		if (empty($this->headers)) {
70 70
 			$headers = $this->mailbox()->imap()->headerinfo($this->msgNumber);
71
-			foreach ( $headers as $name => $value ) {
72
-				$this->headers[ strtolower($name) ] = $value;
71
+			foreach ($headers as $name => $value) {
72
+				$this->headers[strtolower($name)] = $value;
73 73
 			}
74 74
 		}
75 75
 
76 76
 		return $this->headers;
77 77
 	}
78 78
 
79
-	public function header( $name ) {
79
+	public function header($name) {
80 80
 		$headers = $this->headers();
81
-		return @$headers[ strtolower($name) ];
81
+		return @$headers[strtolower($name)];
82 82
 	}
83 83
 
84
-	public function createMessagePart( $structure, $section ) {
84
+	public function createMessagePart($structure, $section) {
85 85
 		return new IMAPMessagePart($this, $structure, $section);
86 86
 	}
87 87
 
88 88
 	public function parts() {
89
-		if ( empty($this->parts) ) {
89
+		if (empty($this->parts)) {
90 90
 			$structure = $this->structure();
91 91
 
92 92
 			// Possibilities:
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 			// - CALENDAR
101 101
 			// - JPEG
102 102
 
103
-			if ( empty($structure->parts) ) {
103
+			if (empty($structure->parts)) {
104 104
 				$this->parts[] = $this->createMessagePart(
105 105
 					$structure,
106 106
 					[1]
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
 		return $this->parts;
120 120
 	}
121 121
 
122
-	public function allParts( $withContainers = false ) {
122
+	public function allParts($withContainers = false) {
123 123
 		$parts = [];
124 124
 		$iterate = function($message) use (&$iterate, &$parts, $withContainers) {
125
-			foreach ( $message->parts() as $part ) {
126
-				if ( $part->parts() ) {
127
-					if ( $withContainers ) {
125
+			foreach ($message->parts() as $part) {
126
+				if ($part->parts()) {
127
+					if ($withContainers) {
128 128
 						$parts[] = $part;
129 129
 					}
130 130
 
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
 		return $parts;
141 141
 	}
142 142
 
143
-	public function part( $index ) {
143
+	public function part($index) {
144 144
 		$parts = $this->parts();
145 145
 		return @$parts[$index];
146 146
 	}
147 147
 
148 148
 	public function structure() {
149
-		if ( empty($this->structure) ) {
149
+		if (empty($this->structure)) {
150 150
 			$this->structure = $this->mailbox()->imap()->fetchstructure($this->msgNumber);
151 151
 		}
152 152
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	}
155 155
 
156 156
 	public function content() {
157
-		if ( count($this->parts()) == 1 ) {
157
+		if (count($this->parts()) == 1) {
158 158
 			return $this->part(0)->content();
159 159
 		}
160 160
 
@@ -162,16 +162,16 @@  discard block
 block discarded – undo
162 162
 	}
163 163
 
164 164
 	public function parameters() {
165
-		if ( empty($this->parameters) ) {
165
+		if (empty($this->parameters)) {
166 166
 			$structure = $this->structure();
167 167
 
168 168
 			$this->parameters['bytes'] = @$structure->bytes;
169 169
 
170
-			foreach ((array) @$structure->parameters as $param) {
171
-				$this->parameters[ strtolower($param->attribute) ] = $param->value;
170
+			foreach ((array)@$structure->parameters as $param) {
171
+				$this->parameters[strtolower($param->attribute)] = $param->value;
172 172
 			}
173
-			foreach ((array) @$structure->dparameters as $param) {
174
-				$this->parameters[ strtolower($param->attribute) ] = $param->value;
173
+			foreach ((array)@$structure->dparameters as $param) {
174
+				$this->parameters[strtolower($param->attribute)] = $param->value;
175 175
 			}
176 176
 		}
177 177
 
@@ -180,16 +180,16 @@  discard block
 block discarded – undo
180 180
 
181 181
 	public function simpleStructure() {
182 182
 		$parts = [];
183
-		foreach ( $this->allParts(true) as $part ) {
183
+		foreach ($this->allParts(true) as $part) {
184 184
 			$name = '';
185 185
 
186
-			$name .= implode('.', $part->section()) . '. ';
187
-			if ( $part->parts() ) {
186
+			$name .= implode('.', $part->section()).'. ';
187
+			if ($part->parts()) {
188 188
 				$name .= '*';
189 189
 			}
190 190
 			$name .= $part->subtype();
191
-			if ( $bytes = $part->parameter('bytes') ) {
192
-				$name .= ' (' . $bytes . ')';
191
+			if ($bytes = $part->parameter('bytes')) {
192
+				$name .= ' ('.$bytes.')';
193 193
 			}
194 194
 
195 195
 			$parts[] = $name;
Please login to merge, or discard this patch.
src/IMAPTransportInterface.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -4,13 +4,13 @@
 block discarded – undo
4 4
 
5 5
 interface IMAPTransportInterface {
6 6
 
7
-	public function open( $server, $username, $password, $mailbox, array $flags );
7
+	public function open($server, $username, $password, $mailbox, array $flags);
8 8
 	public function headers();
9
-	public function utf8( $string );
10
-	public function headerinfo( $msgNumber );
11
-	public function clearflag( $msgNumber, $flag );
12
-	public function setflag( $msgNumber, $flag );
13
-	public function fetchstructure( $msgNumber );
14
-	public function fetchbody( $msgNumber, $section );
9
+	public function utf8($string);
10
+	public function headerinfo($msgNumber);
11
+	public function clearflag($msgNumber, $flag);
12
+	public function setflag($msgNumber, $flag);
13
+	public function fetchstructure($msgNumber);
14
+	public function fetchbody($msgNumber, $section);
15 15
 
16 16
 }
Please login to merge, or discard this patch.
src/IMAPTransport.php 1 patch
Spacing   +11 added lines, -11 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 imap_headerinfo($this->resource, $msgNumber);
39 39
 	}
40 40
 
41
-	public function clearflag( $msgNumber, $flag ) {
41
+	public function clearflag($msgNumber, $flag) {
42 42
 		return imap_clearflag_full($this->resource, $msgNumber, $flag);
43 43
 	}
44 44
 
45
-	public function setflag( $msgNumber, $flag ) {
45
+	public function setflag($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 imap_fetchbody($this->resource, $msgNumber, implode('.', $section), FT_PEEK);
55 55
 	}
56 56
 
Please login to merge, or discard this patch.
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.