2015-01-29 04:42:25 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class to perform replacement based on a simple hashtable lookup
|
2018-07-10 15:14:29 +00:00
|
|
|
*
|
|
|
|
|
* @deprecated since 1.32, use a Closure instead
|
2015-01-29 04:42:25 +00:00
|
|
|
*/
|
|
|
|
|
class HashtableReplacer extends Replacer {
|
|
|
|
|
private $table, $index;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param array $table
|
|
|
|
|
* @param int $index
|
|
|
|
|
*/
|
2015-01-29 04:46:13 +00:00
|
|
|
public function __construct( $table, $index = 0 ) {
|
2018-07-10 15:14:29 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.32' );
|
2015-01-29 04:42:25 +00:00
|
|
|
$this->table = $table;
|
|
|
|
|
$this->index = $index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param array $matches
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
2015-01-29 04:49:57 +00:00
|
|
|
public function replace( array $matches ) {
|
2015-01-29 04:42:25 +00:00
|
|
|
return $this->table[$matches[$this->index]];
|
|
|
|
|
}
|
|
|
|
|
}
|