-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathTokenRegistry.php
More file actions
46 lines (39 loc) · 1.1 KB
/
TokenRegistry.php
File metadata and controls
46 lines (39 loc) · 1.1 KB
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
<?php
/*
* Copyright (c) Atsuhiro Kubo <kubo@iteman.jp> and contributors,
* All rights reserved.
*
* This file is part of Workflower.
*
* This program and the accompanying materials are made available under
* the terms of the BSD 2-Clause License which accompanies this
* distribution, and is available at http://opensource.org/licenses/BSD-2-Clause
*/
namespace PHPMentors\Workflower\Workflow;
use PHPMentors\Workflower\Workflow\Element\Token;
use PHPMentors\Workflower\Workflow\Event\EndEvent;
/**
* @since 2.0.0
*/
class TokenRegistry
{
private $tokens = [];
public function register(Token $token): void
{
$this->tokens[$token->getId()] = $token;
}
public function remove(Token $token): void
{
unset($this->tokens[$token->getId()]);
}
public function getTokens(): array
{
return array_values($this->tokens);
}
public function getActiveTokens(): array
{
return array_values(array_filter($this->tokens, function (Token $token) {
return !($token->getCurrentFlowObject() instanceof EndEvent);
}));
}
}