blob: 108f499924a52dc9ddfda1b12c3f4965df545585 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
<?php
namespace Mediawiki\Api\Generator;
/**
* @access public
*
* @author Addshore
*
* @since 0.5.1
*/
class FluentGenerator implements ApiGenerator {
private $name;
private $params;
/**
* @param string $name
*/
public function __construct( $name ) {
$this->name = $name;
}
/**
* Convenience method for using this fluidly
*
* @param string $name
*
* @return FluentGenerator
*/
public static function factory( $name ) {
return new self( $name );
}
/**
* @return string[]
*/
public function getParams() {
$params = $this->params;
$params['generator'] = $this->name;
return $params;
}
/**
* @param string $key optionally with the 'g' prefix
* @param string $value
*
* @return $this
*/
public function set( $key, $value ) {
$key = $this->addKeyprefixIfNeeded( $key );
$this->params[$key] = $value;
return $this;
}
/**
* @param string $key
*
* @return string
*/
private function addKeyPrefixIfNeeded( $key ) {
if ( strtolower( substr( $key, 0, 1 ) ) === 'g' ) {
return $key;
}
return 'g' . $key;
}
}
|