Code Duplication    Length = 20-20 lines in 2 locations

src/IMAPMessage.php 1 location

@@ 122-141 (lines=20) @@
119
		return $this->parts;
120
	}
121
122
	public function allParts( $withContainers = false ) {
123
		$parts = [];
124
		$iterate = function($message) use (&$iterate, &$parts, $withContainers) {
125
			foreach ( $message->parts() as $part ) {
126
				if ( $part->parts() ) {
127
					if ( $withContainers ) {
128
						$parts[] = $part;
129
					}
130
131
					$iterate($part);
132
				}
133
				else {
134
					$parts[] = $part;
135
				}
136
			}
137
		};
138
139
		$iterate($this);
140
		return $parts;
141
	}
142
143
	public function part( $index ) {
144
		$parts = $this->parts();

src/IMAPMessagePart.php 1 location

@@ 47-66 (lines=20) @@
44
		}
45
	}
46
47
	public function allParts( $withContainers = false ) {
48
		$parts = [];
49
		$iterate = function($message) use (&$iterate, &$parts, $withContainers) {
50
			foreach ( $message->parts() as $part ) {
51
				if ( $part->parts() ) {
52
					if ( $withContainers ) {
53
						$parts[] = $part;
54
					}
55
56
					$iterate($part);
57
				}
58
				else {
59
					$parts[] = $part;
60
				}
61
			}
62
		};
63
64
		$iterate($this);
65
		return $parts;
66
	}
67
68
	public function part( $index ) {
69
		$parts = $this->parts();