| Total Complexity | 12 |
| Total Lines | 79 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class RecuerdosPersistentesSobreElAcontecimiento |
||
| 8 | { |
||
| 9 | private $_acontecimientoTraumaticoSevero; |
||
| 10 | private $_pregunta7; |
||
| 11 | private $_pregunta8; |
||
| 12 | |||
| 13 | public function __construct |
||
| 14 | ( |
||
| 15 | AcontecimientoTraumaticoSevero $AcontecimientoTraumaticoSevero, |
||
| 16 | string $pregunta7, |
||
| 17 | string $pregunta8 |
||
| 18 | ) |
||
| 19 | { |
||
| 20 | $this->_acontecimientoTraumaticoSevero = $AcontecimientoTraumaticoSevero; |
||
| 21 | $this->_pregunta7 = $this->setPregunta($pregunta7); |
||
| 22 | $this->_pregunta8 = $this->setPregunta($pregunta8); |
||
| 23 | } |
||
| 24 | |||
| 25 | public function pregunta7(): string |
||
| 26 | { |
||
| 27 | return $this->_pregunta7; |
||
| 28 | } |
||
| 29 | |||
| 30 | public function pregunta8(): string |
||
| 31 | { |
||
| 32 | return $this->_pregunta8; |
||
| 33 | } |
||
| 34 | |||
| 35 | private function setPregunta(string $respuesta): string |
||
| 36 | { |
||
| 37 | if($this->existeRespuestaPositivaEnETS()) |
||
| 38 | { |
||
| 39 | if($this->verificarRespuesta($respuesta)) |
||
| 40 | { |
||
| 41 | return $respuesta; |
||
| 42 | } |
||
| 43 | } |
||
| 44 | else |
||
| 45 | { |
||
| 46 | return 'No'; |
||
| 47 | } |
||
| 48 | |||
| 49 | throw new Exception("Error procesando respuesta", 1); |
||
| 50 | |||
| 51 | } |
||
| 52 | |||
| 53 | private function verificarRespuesta(string $respuesta): bool |
||
| 54 | { |
||
| 55 | if($respuesta == 'Sí' || $respuesta == 'No') |
||
| 56 | { |
||
| 57 | return true; |
||
| 58 | } |
||
| 59 | |||
| 60 | return false; |
||
| 61 | } |
||
| 62 | |||
| 63 | /* |
||
| 64 | Prevenir que si en la primer sección del cuestionario de ATS se responde con No a todo se pueda almacenar un sí en otros |
||
| 65 | */ |
||
| 66 | private function existeRespuestaPositivaEnETS(): bool |
||
| 86 | } |
||
| 87 | } |