Accounts   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 47
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 4 1
A register() 0 4 1
A unregister() 0 4 1
A get() 0 3 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: UramnOIL
5
 * Date: 2018/10/05
6
 * Time: 21:41
7
 */
8
9
namespace VectorNetworkProject\DataProvider\Tables\Accounts;
10
11
use pocketmine\IPlayer;
12
use VectorNetworkProject\DataProvider\Tables\TableBase;
13
14
class Accounts extends TableBase
15
{
16
	public const ACCOUNT_INIT = 'userdataprovider.accounts.init';
17
	public const ACCOUNT_REGISTER = 'userdataprovider.accounts.register';
18
	public const ACCOUNT_UNREGISTER = 'userdataprovider.accounts.unregister';
19
	public const ACCOUNT_GET = 'userdataprovider.accounts.get';
20
21
	public function init(): void
22
	{
23
		$this->connector->executeGeneric(self::ACCOUNT_INIT);
24
	}
25
26
	/**
27
	 * プレイヤーを登録します
28
	 *
29
	 * @param IPlayer $player
30
	 * @param callable|null $onInserted
31
	 * @param callable|null $onError
32
	 */
33
	public function register(IPlayer $player, ?callable $onInserted = null, ?callable $onError = null)
34
	{
35
		$this->connector->executeInsert(self::ACCOUNT_REGISTER, [$player->getName()], $onInserted, $onError);
36
	}
37
38
	/**
39
	 * プレイヤーを登録解除します
40
	 *
41
	 * @param IPlayer $player
42
	 * @param callable|null $onSuccess
43
	 * @param callable|null $onError
44
	 */
45
	public function unregister(IPlayer $player, ?callable $onSuccess = null, ?callable $onError = null)
46
	{
47
		$this->connector->executeChange(self::ACCOUNT_UNREGISTER, [$player->getName()], $onSuccess, $onError);
48
	}
49
50
	/**
51
	 * プレイヤーの情報を取得します
52
	 *
53
	 * @param IPlayer $player
54
	 * @param callable|null $onSelect
55
	 * @param callable|null $onError
56
	 */
57
	public function get(IPlayer $player, ?callable $onSelect = null, ?callable $onError = null){
58
		$this->connector->executeSelect(self::ACCOUNT_GET, [$player->getName()], $onSelect, $onError);
59
	}
60
}