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

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