| Code Coverage | ||||||||||
| Lines | Functions and Methods | Classes and Traits | ||||||||
| Total |  | 42.86% | 18 / 42 |  | 25.00% | 1 / 4 | CRAP |  | 0.00% | 0 / 1 | 
| LoginForm |  | 42.86% | 18 / 42 |  | 25.00% | 1 / 4 | 28.66 |  | 0.00% | 0 / 1 | 
| fromLoginParameters |  | 0.00% | 0 / 9 |  | 0.00% | 0 / 1 | 2 | |||
| fromAdditionalParameters |  | 50.00% | 9 / 18 |  | 0.00% | 0 / 1 | 8.12 | |||
| fromQuickLogin |  | 0.00% | 0 / 6 |  | 0.00% | 0 / 1 | 2 | |||
| writeWorkstationUpdate |  | 100.00% | 9 / 9 |  | 100.00% | 1 / 1 | 3 | |||
| 1 | <?php | 
| 2 | |
| 3 | /** | 
| 4 | * | 
| 5 | * @package 115Mandant | 
| 6 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG | 
| 7 | * | 
| 8 | */ | 
| 9 | |
| 10 | namespace BO\Zmsstatistic\Helper; | 
| 11 | |
| 12 | use BO\Mellon\Validator; | 
| 13 | |
| 14 | class LoginForm | 
| 15 | { | 
| 16 | /** | 
| 17 | * form data for reuse in multiple controllers | 
| 18 | */ | 
| 19 | public static function fromLoginParameters() | 
| 20 | { | 
| 21 | $collection = array(); | 
| 22 | // loginName | 
| 23 | $collection['loginName'] = Validator::param('loginName')->isString() | 
| 24 | ->isBiggerThan(2, "Es muss ein aussagekräftiger Name eingegeben werden") | 
| 25 | ->isSmallerThan(40, "Der Name sollte 40 Zeichen nicht überschreiten"); | 
| 26 | |
| 27 | // password | 
| 28 | $collection['password'] = Validator::param('password')->isString() | 
| 29 | ->isBiggerThan(2, "Es muss ein Passwort eingegeben werden") | 
| 30 | ->isSmallerThan(20, "Das Passwort sollte 20 Zeichen nicht überschreiten"); | 
| 31 | |
| 32 | // return validated collection | 
| 33 | $collection = Validator::collection($collection); | 
| 34 | return $collection; | 
| 35 | } | 
| 36 | |
| 37 | /** | 
| 38 | * form data for reuse in multiple controllers | 
| 39 | */ | 
| 40 | public static function fromAdditionalParameters() | 
| 41 | { | 
| 42 | $collection = array(); | 
| 43 | |
| 44 | // scope | 
| 45 | if ('cluster' == Validator::param('scope')->isString()->getValue()) { | 
| 46 | $collection['scope'] = Validator::param('scope') | 
| 47 | ->isString('Bitte wählen Sie einen Standort aus'); | 
| 48 | } else { | 
| 49 | $collection['scope'] = Validator::param('scope') | 
| 50 | ->isNumber('Bitte wählen Sie einen Standort aus'); | 
| 51 | } | 
| 52 | |
| 53 | if (! Validator::param('appointmentsOnly')->isDeclared()->hasFailed()) { | 
| 54 | $collection['appointmentsOnly'] = Validator::param('appointmentsOnly') | 
| 55 | ->isNumber(); | 
| 56 | } | 
| 57 | |
| 58 | // workstation | 
| 59 | if (! Validator::param('workstation')->isDeclared()->hasFailed()) { | 
| 60 | $collection['workstation'] = Validator::param('workstation') | 
| 61 | ->isString('Bitte wählen Sie einen Arbeitsplatz oder den Tresen aus') | 
| 62 | ->isSmallerThan(8, "Die Arbeitsplatz-Bezeichnung sollte 8 Zeichen nicht überschreiten"); | 
| 63 | } | 
| 64 | // hint | 
| 65 | if (! Validator::param('hint')->isDeclared()->hasFailed()) { | 
| 66 | $collection['hint'] = Validator::param('hint') | 
| 67 | ->isString(); | 
| 68 | } | 
| 69 | |
| 70 | // return validated collection | 
| 71 | $collection = Validator::collection($collection); | 
| 72 | return $collection; | 
| 73 | } | 
| 74 | |
| 75 | public static function fromQuickLogin() | 
| 76 | { | 
| 77 | $loginData = static::fromLoginParameters(); | 
| 78 | $additionalData = static::fromAdditionalParameters(); | 
| 79 | $collection = array_merge($loginData->getValues(), $additionalData->getValues()); | 
| 80 | $collection['redirectUrl'] = Validator::param('url')->isString(); | 
| 81 | $collection = Validator::collection($collection); | 
| 82 | return $collection; | 
| 83 | } | 
| 84 | |
| 85 | public static function writeWorkstationUpdate($data, $workstation) | 
| 86 | { | 
| 87 | if (isset($workstation->useraccount)) { | 
| 88 | $formData = $data->getValues(); | 
| 89 | $workstation->setValidatedName($formData); | 
| 90 | $workstation->setValidatedHint($formData); | 
| 91 | $workstation->setValidatedScope($formData); | 
| 92 | $workstation->setValidatedAppointmentsOnly($formData); | 
| 93 | unset($workstation->useraccount['departments']); | 
| 94 | $result = \App::$http->readPostResult('/workstation/', $workstation)->getEntity(); | 
| 95 | } | 
| 96 | return ($result) ? true : false; | 
| 97 | } | 
| 98 | } |