| @@ -30,6 +30,9 @@ discard block | ||
| 30 | 30 | } | 
| 31 | 31 | } | 
| 32 | 32 | |
| 33 | + /** | |
| 34 | + * @param boolean $clear | |
| 35 | + */ | |
| 33 | 36 |  	protected function flags( $flags, $clear ) { | 
| 34 | 37 | $cb = [$this->imap(), $clear ? 'clearflag' : 'setflag']; | 
| 35 | 38 | |
| @@ -74,6 +77,9 @@ discard block | ||
| 74 | 77 | return $this->headers; | 
| 75 | 78 | } | 
| 76 | 79 | |
| 80 | + /** | |
| 81 | + * @param string $name | |
| 82 | + */ | |
| 77 | 83 |  	public function header( $name ) { | 
| 78 | 84 | $headers = $this->headers(); | 
| 79 | 85 | return @$headers[ strtolower($name) ]; | 
| @@ -20,33 +20,33 @@ discard block | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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; | 
| @@ -103,8 +103,7 @@ | ||
| 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, | 
| @@ -7,10 +7,10 @@ | ||
| 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(); | 
| @@ -13,7 +13,7 @@ discard block | ||
| 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,15 +23,15 @@ discard block | ||
| 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 | 28 | |
| 29 | -			while ( count($parts) == 1 && empty($parts[0]->bytes) && !empty($parts[0]->parts) ) { | |
| 29 | +			while (count($parts) == 1 && empty($parts[0]->bytes) && !empty($parts[0]->parts)) { | |
| 30 | 30 | $this->skippedParts[] = $parts[0]; | 
| 31 | 31 | $parts = $parts[0]->parts; | 
| 32 | 32 | } | 
| 33 | 33 | |
| 34 | -			foreach ( $parts as $n => $part ) { | |
| 34 | +			foreach ($parts as $n => $part) { | |
| 35 | 35 | $this->parts[] = $this->message()->createMessagePart( | 
| 36 | 36 | $part, | 
| 37 | 37 | array_merge($this->section(), [$n+1]) | 
| @@ -54,7 +54,7 @@ discard block | ||
| 54 | 54 | return $this->decode($body); | 
| 55 | 55 | } | 
| 56 | 56 | |
| 57 | -	public function decode( $content ) { | |
| 57 | +	public function decode($content) { | |
| 58 | 58 | return quoted_printable_decode($content); | 
| 59 | 59 | } | 
| 60 | 60 | |
| @@ -8,12 +8,12 @@ discard block | ||
| 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 | ||
| 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 | } |