Code Duplication    Length = 20-20 lines in 2 locations

src/IMAPMessage.php 1 location

@@ 110-129 (lines=20) @@
107
		return $this->parts;
108
	}
109
110
	public function allParts( $withContainers = false ) {
111
		$parts = [];
112
		$iterate = function($message) use (&$iterate, &$parts, $withContainers) {
113
			foreach ( $message->parts() as $part ) {
114
				if ( $part->parts() ) {
115
					if ( $withContainers ) {
116
						$parts[] = $part;
117
					}
118
119
					$iterate($part);
120
				}
121
				else {
122
					$parts[] = $part;
123
				}
124
			}
125
		};
126
127
		$iterate($this);
128
		return $parts;
129
	}
130
131
	public function part( $index ) {
132
		$parts = $this->parts();

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();