Code Duplication    Length = 8-10 lines in 2 locations

projects/plugins/jetpack/_inc/lib/class.media-extractor.php 2 locations

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