Code Duplication    Length = 15-15 lines in 2 locations

includes/api/ApiBase.php 2 locations

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