Code Duplication    Length = 20-20 lines in 2 locations

src/IMAPMessagePart.php 1 location

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

src/IMAPMessage.php 1 location

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