Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
31 / 31
100.00% covered (success)
100.00%
6 / 6
CRAP
100.00% covered (success)
100.00%
1 / 1
ClusterHelper
100.00% covered (success)
100.00%
31 / 31
100.00% covered (success)
100.00%
6 / 6
11
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getEntity
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getScopeList
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getProcessList
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
1 / 1
3
 getNextProcess
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
1 / 1
3
 isClusterEnabled
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3/**
4 *
5 * @package Zmsappointment
6 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
7 *
8 */
9
10namespace BO\Zmsadmin\Helper;
11
12use BO\Zmsentities\Workstation;
13use BO\Zmsentities\Collection\ProcessList;
14
15class ClusterHelper
16{
17    protected static $cluster = null;
18
19    protected static $workstation = null;
20
21    public function __construct(Workstation $workstation)
22    {
23        static::$workstation = $workstation;
24        static::$cluster = \App::$http->readGetResult('/scope/' . $workstation->scope['id'] . '/cluster/')->getEntity();
25    }
26
27    public static function getEntity()
28    {
29        return static::$cluster;
30    }
31
32    public static function getScopeList()
33    {
34        return static::$workstation->getScopeList(static::$cluster);
35    }
36
37    public static function getProcessList($selectedDate)
38    {
39        if (static::isClusterEnabled()) {
40            $processList = \App::$http
41                ->readGetResult(
42                    '/cluster/' . static::$cluster->id . '/process/' . $selectedDate . '/',
43                    ['gql' => GraphDefaults::getProcess()]
44                );
45        } else {
46            $processList = \App::$http
47                ->readGetResult(
48                    '/scope/' . static::$workstation->scope['id'] . '/process/' . $selectedDate . '/',
49                    ['gql' => GraphDefaults::getProcess()]
50                );
51        }
52        return ($processList) ? $processList->getCollection() : new ProcessList();
53    }
54
55    public static function getNextProcess($excludedIds)
56    {
57        $exclude = is_array($excludedIds) ? ExcludeIds::toQuery($excludedIds) : (string) $excludedIds;
58        if (static::isClusterEnabled()) {
59            $nextProcess =  \App::$http->readGetResult(
60                '/cluster/' . static::$cluster['id'] . '/queue/next/',
61                [
62                    'exclude' => $exclude,
63                    'allowClusterWideCall' => \App::$allowClusterWideCall
64                ]
65            )?->getEntity();
66        } else {
67            $nextProcess = \App::$http->readGetResult(
68                '/scope/' . static::$workstation->scope['id'] . '/queue/next/',
69                ['exclude' => $exclude]
70            )?->getEntity();
71        }
72
73        return $nextProcess;
74    }
75
76    public static function isClusterEnabled()
77    {
78        return (static::$workstation->queue['clusterEnabled'] && static::$cluster);
79    }
80}