Code Duplication    Length = 12-13 lines in 5 locations

includes/cli/class-wc-cli-customer.php 1 location

@@ 635-646 (lines=12) @@
632
	 * @param  string $email the customer's email
633
	 * @return string the URL to the customer's avatar
634
	 */
635
	protected function get_avatar_url( $email ) {
636
		$avatar_html = get_avatar( $email );
637
638
		// Get the URL of the avatar from the provided HTML
639
		preg_match( '/src=["|\'](.+)[\&|"|\']/U', $avatar_html, $matches );
640
641
		if ( isset( $matches[1] ) && ! empty( $matches[1] ) ) {
642
			return esc_url_raw( $matches[1] );
643
		}
644
645
		return null;
646
	}
647
648
	/**
649
	 * Add/Update customer data.

includes/api/legacy/v1/class-wc-api-customers.php 1 location

@@ 427-439 (lines=13) @@
424
	 * @param string $email the customer's email
425
	 * @return string the URL to the customer's avatar
426
	 */
427
	private function get_avatar_url( $email ) {
428
429
		$avatar_html = get_avatar( $email );
430
431
		// Get the URL of the avatar from the provided HTML
432
		preg_match( '/src=["|\'](.+)[\&|"|\']/U', $avatar_html, $matches );
433
434
		if ( isset( $matches[1] ) && ! empty( $matches[1] ) ) {
435
			return esc_url_raw( $matches[1] );
436
		}
437
438
		return null;
439
	}
440
441
	/**
442
	 * Validate the request by checking:

includes/api/legacy/v2/class-wc-api-customers.php 1 location

@@ 692-703 (lines=12) @@
689
	 * @param string $email the customer's email
690
	 * @return string the URL to the customer's avatar
691
	 */
692
	private function get_avatar_url( $email ) {
693
		$avatar_html = get_avatar( $email );
694
695
		// Get the URL of the avatar from the provided HTML
696
		preg_match( '/src=["|\'](.+)[\&|"|\']/U', $avatar_html, $matches );
697
698
		if ( isset( $matches[1] ) && ! empty( $matches[1] ) ) {
699
			return esc_url_raw( $matches[1] );
700
		}
701
702
		return null;
703
	}
704
705
	/**
706
	 * Validate the request by checking:

includes/api/legacy/v3/class-wc-api-customers.php 1 location

@@ 681-692 (lines=12) @@
678
	 * @param string $email the customer's email
679
	 * @return string the URL to the customer's avatar
680
	 */
681
	private function get_avatar_url( $email ) {
682
		$avatar_html = get_avatar( $email );
683
684
		// Get the URL of the avatar from the provided HTML
685
		preg_match( '/src=["|\'](.+)[\&|"|\']/U', $avatar_html, $matches );
686
687
		if ( isset( $matches[1] ) && ! empty( $matches[1] ) ) {
688
			return esc_url_raw( $matches[1] );
689
		}
690
691
		return null;
692
	}
693
694
	/**
695
	 * Validate the request by checking:

includes/wc-user-functions.php 1 location

@@ 661-672 (lines=12) @@
658
 * @param string $email the customer's email.
659
 * @return string the URL to the customer's avatar.
660
 */
661
function wc_get_customer_avatar_url( $email ) {
662
	$avatar_html = get_avatar( $email );
663
664
	// Get the URL of the avatar from the provided HTML.
665
	preg_match( '/src=["|\'](.+)[\&|"|\']/U', $avatar_html, $matches );
666
667
	if ( isset( $matches[1] ) && ! empty( $matches[1] ) ) {
668
		return esc_url_raw( $matches[1] );
669
	}
670
671
	return null;
672
}
673