Code Duplication    Length = 15-15 lines in 2 locations

includes/api/ApiBase.php 2 locations

@@ 740-754 (lines=15) @@
737
	 * @param array $params User provided set of parameters, as from $this->extractRequestParams()
738
	 * @param string $required,... Names of parameters of which at most one must be set
739
	 */
740
	public function requireMaxOneParameter( $params, $required /*...*/ ) {
741
		$required = func_get_args();
742
		array_shift( $required );
743
		$p = $this->getModulePrefix();
744
745
		$intersection = array_intersect( array_keys( array_filter( $params,
746
			[ $this, 'parameterNotEmpty' ] ) ), $required );
747
748
		if ( count( $intersection ) > 1 ) {
749
			$this->dieUsage(
750
				"The parameters {$p}" . implode( ", {$p}", $intersection ) . ' can not be used together',
751
				'invalidparammix'
752
			);
753
		}
754
	}
755
756
	/**
757
	 * Die if none of a certain set of parameters is set and not false.
@@ 763-777 (lines=15) @@
760
	 * @param array $params User provided set of parameters, as from $this->extractRequestParams()
761
	 * @param string $required,... Names of parameters of which at least one must be set
762
	 */
763
	public function requireAtLeastOneParameter( $params, $required /*...*/ ) {
764
		$required = func_get_args();
765
		array_shift( $required );
766
		$p = $this->getModulePrefix();
767
768
		$intersection = array_intersect(
769
			array_keys( array_filter( $params, [ $this, 'parameterNotEmpty' ] ) ),
770
			$required
771
		);
772
773
		if ( count( $intersection ) == 0 ) {
774
			$this->dieUsage( "At least one of the parameters {$p}" .
775
				implode( ", {$p}", $required ) . ' is required', "{$p}missingparam" );
776
		}
777
	}
778
779
	/**
780
	 * Die if any of the specified parameters were found in the query part of