| Conditions | 2 |
| Paths | 4 |
| Total Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | public function validate($value, Constraint $constraint) |
||
| 27 | { |
||
| 28 | $tempFile = tempnam(sys_get_temp_dir(), 'composer'); |
||
| 29 | file_put_contents($tempFile, $value); |
||
| 30 | |||
| 31 | try { |
||
| 32 | $jsonFile = new JsonFile($tempFile); |
||
| 33 | $jsonFile->validateSchema(JsonFile::LAX_SCHEMA); |
||
| 34 | unlink($tempFile); |
||
| 35 | } catch (\Exception $exception) { |
||
| 36 | unlink($tempFile); |
||
| 37 | $from = [$tempFile]; |
||
| 38 | $to = ['composer.json']; |
||
| 39 | $this->context->addViolation(str_replace($from, $to, $exception->getMessage())); |
||
| 40 | } |
||
| 41 | } |
||
| 42 | } |
||
| 43 |