| Conditions | 3 |
| Paths | 3 |
| Total Lines | 25 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 3.0123 |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | */ |
||
| 27 | 8 | public function run(): ARContract |
|
| 28 | { |
||
| 29 | 8 | $request = Yii::$app->getRequest(); |
|
| 30 | /* @var $model ARContract */ |
||
| 31 | 8 | $model = new ($this->modelClass)([ |
|
|
|
|||
| 32 | 8 | 'scenario' => $this->scenario, |
|
| 33 | ]); |
||
| 34 | 8 | $model->load( |
|
| 35 | 8 | $request->getQueryParams() + $request->getBodyParams(), |
|
| 36 | 8 | '' |
|
| 37 | ); |
||
| 38 | 8 | $this->checkAccess($model, $request->getQueryParams()); |
|
| 39 | 8 | $model->load($this->parseFileAttributes(), ''); |
|
| 40 | 8 | if ($model->save()) { |
|
| 41 | 2 | $response = Yii::$app->getResponse(); |
|
| 42 | 2 | $response->setStatusCode(201); |
|
| 43 | 2 | $response->getHeaders()->set('Location', $model->getSelfLink()); |
|
| 44 | 6 | } elseif (!$model->hasErrors()) { |
|
| 45 | throw new ServerErrorHttpException( |
||
| 46 | 'Failed to create the object for unknown reason.' |
||
| 47 | ); |
||
| 48 | } |
||
| 49 | |||
| 50 | 8 | return $model; |
|
| 51 | } |
||
| 53 |