Completed
Push — master ( 96493e...0a3238 )
by Rudie
02:06
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
Spacing   +12 added lines, -12 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,31 +29,31 @@  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 59
 }
Please login to merge, or discard this patch.
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.
src/IMAPMessage.php 2 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -20,33 +20,33 @@  discard block
 block discarded – undo
20 20
 	// protected $HTMLBody;
21 21
 	// protected $attachments = []; // Array<IMAPMessageAttachment>
22 22
 
23
-	public function __construct( IMAPMailbox $mailbox, $msgNumber, $unseen = null ) {
23
+	public function __construct(IMAPMailbox $mailbox, $msgNumber, $unseen = null) {
24 24
 		$this->mailbox = $mailbox;
25 25
 		$this->msgNumber = $msgNumber;
26 26
 		$this->unseen = $unseen;
27 27
 
28
-		if ( $unseen === null ) {
29
-			$this->unseen = (bool) trim($this->header('unseen'));
28
+		if ($unseen === null) {
29
+			$this->unseen = (bool)trim($this->header('unseen'));
30 30
 		}
31 31
 	}
32 32
 
33
-	protected function flags( $flags, $clear ) {
33
+	protected function flags($flags, $clear) {
34 34
 		$cb = [$this->imap(), $clear ? 'clearflag' : 'setflag'];
35 35
 
36 36
 		$feedback = [];
37
-		foreach ( (array)$flags AS $flag ) {
38
-			$flag = '\\' . ucfirst($flag);
37
+		foreach ((array)$flags AS $flag) {
38
+			$flag = '\\'.ucfirst($flag);
39 39
 			$feedback[] = call_user_func($cb, $this->msgNumber, $flag);
40 40
 		}
41 41
 
42 42
 		return is_array($flags) ? $feedback : $feedback[0];
43 43
 	}
44 44
 
45
-	public function flag( $flags ) {
45
+	public function flag($flags) {
46 46
 		return $this->flags($flags, false);
47 47
 	}
48 48
 
49
-	public function unflag( $flags ) {
49
+	public function unflag($flags) {
50 50
 		return $this->flags($flags, true);
51 51
 	}
52 52
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	}
56 56
 
57 57
 	public function subject() {
58
-		if ( empty($this->subject) ) {
58
+		if (empty($this->subject)) {
59 59
 			$subject = $this->mailbox()->imap()->utf8($this->header('subject'));
60 60
 			$this->subject = trim($subject);
61 61
 		}
@@ -64,27 +64,27 @@  discard block
 block discarded – undo
64 64
 	}
65 65
 
66 66
 	public function headers() {
67
-		if ( empty($this->headers) ) {
67
+		if (empty($this->headers)) {
68 68
 			$headers = $this->mailbox()->imap()->headerinfo($this->msgNumber);
69
-			foreach ( $headers as $name => $value ) {
70
-				$this->headers[ strtolower($name) ] = $value;
69
+			foreach ($headers as $name => $value) {
70
+				$this->headers[strtolower($name)] = $value;
71 71
 			}
72 72
 		}
73 73
 
74 74
 		return $this->headers;
75 75
 	}
76 76
 
77
-	public function header( $name ) {
77
+	public function header($name) {
78 78
 		$headers = $this->headers();
79
-		return @$headers[ strtolower($name) ];
79
+		return @$headers[strtolower($name)];
80 80
 	}
81 81
 
82
-	public function createMessagePart( $structure, $section ) {
82
+	public function createMessagePart($structure, $section) {
83 83
 		return new IMAPMessagePart($this, $structure, $section);
84 84
 	}
85 85
 
86 86
 	public function parts() {
87
-		if ( empty($this->parts) ) {
87
+		if (empty($this->parts)) {
88 88
 			$structure = $this->structure();
89 89
 
90 90
 			// Possibilities:
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 			// - CALENDAR
99 99
 			// - JPEG
100 100
 
101
-			if ( empty($structure->parts) ) {
101
+			if (empty($structure->parts)) {
102 102
 				$this->parts[] = $this->createMessagePart(
103 103
 					$structure,
104 104
 					[1]
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	}
119 119
 
120 120
 	public function structure() {
121
-		if ( empty($this->structure) ) {
121
+		if (empty($this->structure)) {
122 122
 			$this->structure = $this->mailbox()->imap()->fetchstructure($this->msgNumber);
123 123
 		}
124 124
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	}
127 127
 
128 128
 	public function content() {
129
-		if ( count($this->parts()) == 1 ) {
129
+		if (count($this->parts()) == 1) {
130 130
 			return $this->part(0)->content();
131 131
 		}
132 132
 
@@ -135,16 +135,16 @@  discard block
 block discarded – undo
135 135
 
136 136
 	public function simpleStructure() {
137 137
 		$parts = [];
138
-		foreach ( $this->allParts(true) as $part ) {
138
+		foreach ($this->allParts(true) as $part) {
139 139
 			$name = '';
140 140
 
141
-			$name .= implode('.', $part->section()) . '. ';
142
-			if ( $part->parts() ) {
141
+			$name .= implode('.', $part->section()).'. ';
142
+			if ($part->parts()) {
143 143
 				$name .= '*';
144 144
 			}
145 145
 			$name .= $part->subtype();
146
-			if ( $bytes = $part->parameter('bytes') ) {
147
-				$name .= ' (' . $bytes . ')';
146
+			if ($bytes = $part->parameter('bytes')) {
147
+				$name .= ' ('.$bytes.')';
148 148
 			}
149 149
 
150 150
 			$parts[] = $name;
Please login to merge, or discard this patch.
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.
src/IMAPMessagePart.php 1 patch
Spacing   +5 added lines, -5 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])
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		return $this->decode($body);
54 54
 	}
55 55
 
56
-	public function decode( $content ) {
56
+	public function decode($content) {
57 57
 		return quoted_printable_decode($content);
58 58
 	}
59 59
 
Please login to merge, or discard this patch.
src/IMAPTransportInterface.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@
 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
 	public function expunge();
16
-	public function delete( $msgNumber );
16
+	public function delete($msgNumber);
17 17
 	public function mailboxmsginfo();
18 18
 
19 19
 }
Please login to merge, or discard this patch.
src/IMAPTransport.php 1 patch
Spacing   +12 added lines, -12 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
 
@@ -58,7 +58,7 @@  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
 
Please login to merge, or discard this patch.