Code Duplication    Length = 8-10 lines in 2 locations

_inc/lib/class.media-extractor.php 2 locations

@@ 118-127 (lines=10) @@
115
116
		// ----------------------------------- MENTIONS ------------------------------
117
118
		if ( self::MENTIONS & $what_to_extract ) {
119
			if ( preg_match_all( '/(^|\s)@(\w+)/u', $stripped_content, $matches ) ) {
120
				$mentions             = array_values( array_unique( $matches[2] ) ); // array_unique() retains the keys!
121
				$mentions             = array_map( 'strtolower', $mentions );
122
				$extracted['mention'] = array( 'name' => $mentions );
123
				if ( ! isset( $extracted['has'] ) ) {
124
					$extracted['has'] = array();
125
				}
126
				$extracted['has']['mention'] = count( $mentions );
127
			}
128
		}
129
130
		// ----------------------------------- HASHTAGS ------------------------------
@@ 140-147 (lines=8) @@
137
			// This regex does not exactly match Twitter's
138
			// if there are problems/complaints we should implement this:
139
			// https://github.com/twitter/twitter-text/blob/master/java/src/com/twitter/Regex.java .
140
			if ( preg_match_all( '/(?:^|\s)#(\w*\p{L}+\w*)/u', $stripped_content, $matches ) ) {
141
				$hashtags             = array_values( array_unique( $matches[1] ) ); // array_unique() retains the keys!
142
				$hashtags             = array_map( 'strtolower', $hashtags );
143
				$extracted['hashtag'] = array( 'name' => $hashtags );
144
				if ( ! isset( $extracted['has'] ) ) {
145
					$extracted['has'] = array();
146
				}
147
				$extracted['has']['hashtag'] = count( $hashtags );
148
			}
149
		}
150