Code Duplication    Length = 24-24 lines in 2 locations

json-endpoints/jetpack/class.jetpack-json-api-modules-endpoint.php 1 location

@@ 42-65 (lines=24) @@
39
	 *
40
	 * @return bool
41
	 */
42
	protected function validate_input( $module) {
43
		$args = $this->input();
44
		// lets set what modules were requested, and validate them
45
		if ( ! isset( $module ) || empty( $module ) ) {
46
47
			if ( ! $args['modules'] || empty( $args['modules'] ) ) {
48
				return new WP_Error( 'missing_module', __( 'You are required to specify a module.', 'jetpack' ), 400 );
49
			}
50
			if ( is_array( $args['modules'] ) ) {
51
				$this->modules = $args['modules'];
52
			} else {
53
				$this->modules[] = $args['modules'];
54
			}
55
		} else {
56
			$this->modules[] = urldecode( $module );
57
			$this->bulk = false;
58
		}
59
60
		if ( is_wp_error( $error = $this->validate_modules() ) ) {
61
			return $error;
62
		}
63
64
		return parent::validate_input( $module );
65
	}
66
67
	/**
68
	 * Walks through submitted themes to make sure they are valid

json-endpoints/jetpack/class.jetpack-json-api-themes-endpoint.php 1 location

@@ 49-72 (lines=24) @@
46
	 *
47
	 * @return bool
48
	 */
49
	protected function validate_input( $theme ) {
50
		$args = $this->input();
51
		// lets set what themes were requested, and validate them
52
		if ( ! isset( $theme ) || empty( $theme ) ) {
53
54
			if ( ! $args['themes'] || empty( $args['themes'] ) ) {
55
				return new WP_Error( 'missing_theme', __( 'You are required to specify a theme to update.', 'jetpack' ), 400 );
56
			}
57
			if ( is_array( $args['themes'] ) ) {
58
				$this->themes = $args['themes'];
59
			} else {
60
				$this->themes[] = $args['themes'];
61
			}
62
		} else {
63
			$this->themes[] = urldecode( $theme );
64
			$this->bulk = false;
65
		}
66
67
		if ( is_wp_error( $error = $this->validate_themes() ) ) {
68
			return $error;
69
		}
70
71
		return parent::validate_input( $theme );
72
	}
73
74
	/**
75
	 * Walks through submitted themes to make sure they are valid