Conditions | 5 |
Paths | 8 |
Total Lines | 27 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 9.85 |
Changes | 0 |
1 | <?php |
||
27 | 1 | public function performAction() |
|
28 | { |
||
29 | 1 | if ($this->schema) { |
|
30 | 1 | $schemaData = $this->readData($this->schema); |
|
31 | try { |
||
32 | 1 | $schema = Schema::import($schemaData); |
|
33 | } catch (InvalidValue $e) { |
||
34 | $this->response->error('Invalid schema'); |
||
35 | $this->response->addContent($e->getMessage()); |
||
36 | die(1); |
||
|
|||
37 | } catch (\Exception $e) { |
||
38 | $this->response->error('Failed to import schema:' . $e->getMessage()); |
||
39 | 1 | die(1); |
|
40 | } |
||
41 | } else { |
||
42 | $schema = new Schema(); |
||
43 | } |
||
44 | |||
45 | 1 | $data = $this->readData($this->data); |
|
46 | |||
47 | try { |
||
48 | 1 | $schema->in($data); |
|
49 | 1 | $this->response->success('Data is valid'); |
|
50 | } catch (InvalidValue $exception) { |
||
51 | $this->response->error('Data is invalid'); |
||
52 | $this->response->addContent($exception->getMessage()); |
||
53 | die(1); |
||
54 | } |
||
56 | } |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.