Complex classes like DefaultControllerMethodsTrait often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use DefaultControllerMethodsTrait, and based on these observations, apply Extract Interface, too.
| 1 | <?php namespace Limoncello\Flute\Http\Traits; |
||
| 57 | trait DefaultControllerMethodsTrait |
||
| 58 | { |
||
| 59 | /** @noinspection PhpTooManyParametersInspection |
||
| 60 | * @param array $queryParams |
||
| 61 | * @param UriInterface $requestUri |
||
| 62 | * @param JsonApiQueryValidatingParserInterface $queryParser |
||
| 63 | * @param ParametersMapperInterface $mapper |
||
| 64 | * @param CrudInterface $crud |
||
| 65 | * @param SettingsProviderInterface $provider |
||
| 66 | * @param JsonSchemasInterface $jsonSchemas |
||
| 67 | * @param EncoderInterface $encoder |
||
| 68 | * |
||
| 69 | * @return ResponseInterface |
||
| 70 | */ |
||
| 71 | 12 | protected static function defaultIndexHandler( |
|
| 72 | array $queryParams, |
||
| 73 | UriInterface $requestUri, |
||
| 74 | JsonApiQueryValidatingParserInterface $queryParser, |
||
| 75 | ParametersMapperInterface $mapper, |
||
| 76 | CrudInterface $crud, |
||
| 77 | SettingsProviderInterface $provider, |
||
| 78 | JsonSchemasInterface $jsonSchemas, |
||
| 79 | EncoderInterface $encoder |
||
| 80 | ): ResponseInterface { |
||
| 81 | 12 | $queryParser->parse($queryParams); |
|
| 82 | |||
| 83 | 11 | $models = $mapper->applyQueryParameters($queryParser, $crud)->index(); |
|
| 84 | |||
| 85 | 10 | $encParams = self::defaultCreateEncodingParameters($queryParser); |
|
| 86 | 10 | $responses = static::defaultCreateResponses($requestUri, $provider, $jsonSchemas, $encoder, $encParams); |
|
| 87 | 10 | $response = ($models->getData()) === null ? |
|
| 88 | 10 | $responses->getCodeResponse(404) : $responses->getContentResponse($models); |
|
| 89 | |||
| 90 | 10 | return $response; |
|
| 91 | } |
||
| 92 | |||
| 93 | /** @noinspection PhpTooManyParametersInspection |
||
| 94 | * @param string $index |
||
| 95 | * @param array $queryParams |
||
| 96 | * @param UriInterface $requestUri |
||
| 97 | * @param JsonApiQueryValidatingParserInterface $queryParser |
||
| 98 | * @param ParametersMapperInterface $mapper |
||
| 99 | * @param CrudInterface $crud |
||
| 100 | * @param SettingsProviderInterface $provider |
||
| 101 | * @param JsonSchemasInterface $jsonSchemas |
||
| 102 | * @param EncoderInterface $encoder |
||
| 103 | * |
||
| 104 | * @return ResponseInterface |
||
| 105 | */ |
||
| 106 | 1 | protected static function defaultReadHandler( |
|
| 107 | string $index, |
||
| 108 | array $queryParams, |
||
| 109 | UriInterface $requestUri, |
||
| 110 | JsonApiQueryValidatingParserInterface $queryParser, |
||
| 111 | ParametersMapperInterface $mapper, |
||
| 112 | CrudInterface $crud, |
||
| 113 | SettingsProviderInterface $provider, |
||
| 114 | JsonSchemasInterface $jsonSchemas, |
||
| 115 | EncoderInterface $encoder |
||
| 116 | ): ResponseInterface { |
||
| 117 | 1 | $queryParser->parse($queryParams); |
|
| 118 | |||
| 119 | 1 | $model = $mapper->applyQueryParameters($queryParser, $crud)->read($index); |
|
| 120 | 1 | assert(!($model instanceof PaginatedDataInterface)); |
|
| 121 | |||
| 122 | 1 | $encParams = self::defaultCreateEncodingParameters($queryParser); |
|
| 123 | 1 | $responses = static::defaultCreateResponses($requestUri, $provider, $jsonSchemas, $encoder, $encParams); |
|
| 124 | 1 | $response = $model === null ? |
|
| 125 | 1 | $responses->getCodeResponse(404) : $responses->getContentResponse($model); |
|
| 126 | |||
| 127 | 1 | return $response; |
|
| 128 | } |
||
| 129 | |||
| 130 | /** @noinspection PhpTooManyParametersInspection |
||
| 131 | * @param Closure $apiHandler |
||
| 132 | * @param array $queryParams |
||
| 133 | * @param UriInterface $requestUri |
||
| 134 | * @param JsonApiQueryValidatingParserInterface $queryParser |
||
| 135 | * @param ParametersMapperInterface $mapper |
||
| 136 | * @param CrudInterface $crud |
||
| 137 | * @param SettingsProviderInterface $provider |
||
| 138 | * @param JsonSchemasInterface $jsonSchemas |
||
| 139 | * @param EncoderInterface $encoder |
||
| 140 | * |
||
| 141 | * @return ResponseInterface |
||
| 142 | */ |
||
| 143 | 2 | protected static function defaultReadRelationshipWithClosureHandler( |
|
| 144 | Closure $apiHandler, |
||
| 145 | array $queryParams, |
||
| 146 | UriInterface $requestUri, |
||
| 147 | JsonApiQueryValidatingParserInterface $queryParser, |
||
| 148 | ParametersMapperInterface $mapper, |
||
| 149 | CrudInterface $crud, |
||
| 150 | SettingsProviderInterface $provider, |
||
| 151 | JsonSchemasInterface $jsonSchemas, |
||
| 152 | EncoderInterface $encoder |
||
| 153 | ): ResponseInterface { |
||
| 154 | 2 | $queryParser->parse($queryParams); |
|
| 155 | 2 | $mapper->applyQueryParameters($queryParser, $crud); |
|
| 156 | |||
| 157 | 2 | $relData = call_user_func($apiHandler); |
|
| 158 | |||
| 159 | 2 | $encParams = self::defaultCreateEncodingParameters($queryParser); |
|
| 160 | 2 | $responses = static::defaultCreateResponses($requestUri, $provider, $jsonSchemas, $encoder, $encParams); |
|
| 161 | |||
| 162 | 2 | $noData = $relData === null || ($relData instanceof PaginatedDataInterface && $relData->getData() === null); |
|
| 163 | 2 | $response = $noData === true ? $responses->getCodeResponse(404) : $responses->getContentResponse($relData); |
|
| 164 | |||
| 165 | 2 | return $response; |
|
| 166 | } |
||
| 167 | |||
| 168 | /** @noinspection PhpTooManyParametersInspection |
||
| 169 | * @param Closure $apiHandler |
||
| 170 | * @param array $queryParams |
||
| 171 | * @param UriInterface $requestUri |
||
| 172 | * @param JsonApiQueryValidatingParserInterface $queryParser |
||
| 173 | * @param ParametersMapperInterface $mapper |
||
| 174 | * @param CrudInterface $crud |
||
| 175 | * @param SettingsProviderInterface $provider |
||
| 176 | * @param JsonSchemasInterface $jsonSchemas |
||
| 177 | * @param EncoderInterface $encoder |
||
| 178 | * |
||
| 179 | * @return ResponseInterface |
||
| 180 | */ |
||
| 181 | 1 | protected static function defaultReadRelationshipIdentifiersWithClosureHandler( |
|
| 182 | Closure $apiHandler, |
||
| 183 | array $queryParams, |
||
| 184 | UriInterface $requestUri, |
||
| 185 | JsonApiQueryValidatingParserInterface $queryParser, |
||
| 186 | ParametersMapperInterface $mapper, |
||
| 187 | CrudInterface $crud, |
||
| 188 | SettingsProviderInterface $provider, |
||
| 189 | JsonSchemasInterface $jsonSchemas, |
||
| 190 | EncoderInterface $encoder |
||
| 191 | ): ResponseInterface { |
||
| 192 | 1 | $queryParser->parse($queryParams); |
|
| 193 | 1 | $mapper->applyQueryParameters($queryParser, $crud); |
|
| 194 | |||
| 195 | 1 | $relData = call_user_func($apiHandler); |
|
| 196 | |||
| 197 | 1 | $encParams = self::defaultCreateEncodingParameters($queryParser); |
|
| 198 | 1 | $responses = static::defaultCreateResponses($requestUri, $provider, $jsonSchemas, $encoder, $encParams); |
|
| 199 | |||
| 200 | 1 | $noData = $relData === null || ($relData instanceof PaginatedDataInterface && $relData->getData() === null); |
|
| 201 | 1 | $response = $noData === true ? $responses->getCodeResponse(404) : $responses->getIdentifiersResponse($relData); |
|
| 202 | |||
| 203 | 1 | return $response; |
|
| 204 | } |
||
| 205 | |||
| 206 | /** @noinspection PhpTooManyParametersInspection |
||
| 207 | * @param UriInterface $requestUri |
||
| 208 | * @param string $requestBody |
||
| 209 | * @param string $schemaClass |
||
| 210 | * @param ModelSchemaInfoInterface $schemaInfo |
||
| 211 | * @param JsonApiDataValidatingParserInterface $validator |
||
| 212 | * @param CrudInterface $crud |
||
| 213 | * @param SettingsProviderInterface $provider |
||
| 214 | * @param JsonSchemasInterface $jsonSchemas |
||
| 215 | * @param EncoderInterface $encoder |
||
| 216 | * @param FactoryInterface $errorFactory |
||
| 217 | * @param FormatterFactoryInterface $formatterFactory |
||
| 218 | * |
||
| 219 | * @return ResponseInterface |
||
| 220 | * |
||
| 221 | * @SuppressWarnings(PHPMD.ExcessiveParameterList) |
||
| 222 | */ |
||
| 223 | 1 | protected static function defaultCreateHandler( |
|
| 250 | |||
| 251 | /** |
||
| 252 | * @param string $requestBody |
||
| 253 | * @param string $schemaClass |
||
| 254 | * @param ModelSchemaInfoInterface $schemaInfo |
||
| 255 | * @param JsonApiDataValidatingParserInterface $validator |
||
| 256 | * @param CrudInterface $crud |
||
| 257 | * @param FactoryInterface $errorFactory |
||
| 258 | * @param FormatterFactoryInterface $formatterFactory |
||
| 259 | * |
||
| 260 | * @return ResponseInterface |
||
|
|
|||
| 261 | */ |
||
| 262 | 1 | protected static function defaultCreate( |
|
| 280 | |||
| 281 | /** |
||
| 282 | * @param string $index |
||
| 283 | * @param UriInterface $requestUri |
||
| 284 | * @param CrudInterface $crud |
||
| 285 | * @param SettingsProviderInterface $provider |
||
| 286 | * @param JsonSchemasInterface $jsonSchemas |
||
| 287 | * @param EncoderInterface $encoder |
||
| 288 | * |
||
| 289 | * @return ResponseInterface |
||
| 290 | */ |
||
| 291 | 1 | protected static function defaultCreateResponse( |
|
| 292 | string $index, |
||
| 293 | UriInterface $requestUri, |
||
| 294 | CrudInterface $crud, |
||
| 295 | SettingsProviderInterface $provider, |
||
| 296 | JsonSchemasInterface $jsonSchemas, |
||
| 297 | EncoderInterface $encoder |
||
| 298 | ): ResponseInterface { |
||
| 299 | 1 | $model = $crud->read($index); |
|
| 300 | 1 | assert($model !== null && !($model instanceof PaginatedDataInterface)); |
|
| 301 | |||
| 302 | 1 | $encParams = null; |
|
| 303 | 1 | $responses = static::defaultCreateResponses($requestUri, $provider, $jsonSchemas, $encoder, $encParams); |
|
| 304 | 1 | $response = $responses->getCreatedResponse($model); |
|
| 305 | |||
| 306 | 1 | return $response; |
|
| 307 | } |
||
| 308 | |||
| 309 | /** @noinspection PhpTooManyParametersInspection |
||
| 310 | * @param string $index |
||
| 311 | * @param UriInterface $requestUri |
||
| 312 | * @param string $requestBody |
||
| 313 | * @param string $schemaClass |
||
| 314 | * @param ModelSchemaInfoInterface $schemaInfo |
||
| 315 | * @param JsonApiDataValidatingParserInterface $validator |
||
| 316 | * @param CrudInterface $crud |
||
| 317 | * @param SettingsProviderInterface $provider |
||
| 318 | * @param JsonSchemasInterface $jsonSchemas |
||
| 319 | * @param EncoderInterface $encoder |
||
| 320 | * @param FactoryInterface $errorFactory |
||
| 321 | * @param FormatterFactoryInterface $formatterFactory |
||
| 322 | * @param string $messagesNamespace |
||
| 323 | * @param string $errorMessage |
||
| 324 | * |
||
| 325 | * @return ResponseInterface |
||
| 326 | * |
||
| 327 | * @SuppressWarnings(PHPMD.ExcessiveParameterList) |
||
| 328 | */ |
||
| 329 | 6 | protected static function defaultUpdateHandler( |
|
| 362 | |||
| 363 | /** @noinspection PhpTooManyParametersInspection |
||
| 364 | * @param string $index |
||
| 365 | * @param string $requestBody |
||
| 366 | * @param string $schemaClass |
||
| 367 | * @param ModelSchemaInfoInterface $schemaInfo |
||
| 368 | * @param JsonApiDataValidatingParserInterface $validator |
||
| 369 | * @param CrudInterface $crud |
||
| 370 | * @param FactoryInterface $errorFactory |
||
| 371 | * @param FormatterFactoryInterface $formatterFactory |
||
| 372 | * @param string $messagesNamespace |
||
| 373 | * @param string $errorMessage |
||
| 374 | * |
||
| 375 | * @return int |
||
| 376 | * |
||
| 377 | * @SuppressWarnings(PHPMD.ElseExpression) |
||
| 378 | * @SuppressWarnings(PHPMD.ExcessiveParameterList) |
||
| 379 | */ |
||
| 380 | 6 | protected static function defaultUpdate( |
|
| 416 | |||
| 417 | /** |
||
| 418 | * @param int $updated |
||
| 419 | * @param string $index |
||
| 420 | * @param UriInterface $requestUri |
||
| 421 | * @param CrudInterface $crud |
||
| 422 | * @param SettingsProviderInterface $provider |
||
| 423 | * @param JsonSchemasInterface $jsonSchemas |
||
| 424 | * @param EncoderInterface $encoder |
||
| 425 | * |
||
| 426 | * @return ResponseInterface |
||
| 427 | * |
||
| 428 | * @SuppressWarnings(PHPMD.ElseExpression) |
||
| 429 | */ |
||
| 430 | 3 | protected static function defaultUpdateResponse( |
|
| 431 | int $updated, |
||
| 432 | string $index, |
||
| 433 | UriInterface $requestUri, |
||
| 434 | CrudInterface $crud, |
||
| 435 | SettingsProviderInterface $provider, |
||
| 436 | JsonSchemasInterface $jsonSchemas, |
||
| 437 | EncoderInterface $encoder |
||
| 438 | ): ResponseInterface { |
||
| 439 | 3 | $encParams = null; |
|
| 440 | 3 | $responses = static::defaultCreateResponses($requestUri, $provider, $jsonSchemas, $encoder, $encParams); |
|
| 441 | 3 | if ($updated > 0 && ($model = $crud->read($index)) !== null) { |
|
| 442 | 2 | assert(!($model instanceof PaginatedDataInterface)); |
|
| 443 | 2 | $response = $responses->getContentResponse($model); |
|
| 444 | } else { |
||
| 445 | 1 | $response = $responses->getCodeResponse(404); |
|
| 446 | } |
||
| 447 | |||
| 448 | 3 | return $response; |
|
| 449 | } |
||
| 450 | |||
| 451 | /** @noinspection PhpTooManyParametersInspection |
||
| 452 | * @param string $parentIndex |
||
| 453 | * @param string $modelRelName |
||
| 454 | * @param string $childIndex |
||
| 455 | * @param UriInterface $requestUri |
||
| 456 | * @param string $requestBody |
||
| 457 | * @param string $childSchemaClass |
||
| 458 | * @param ModelSchemaInfoInterface $schemaInfo |
||
| 459 | * @param JsonApiDataValidatingParserInterface $childValidator |
||
| 460 | * @param CrudInterface $parentCrud |
||
| 461 | * @param CrudInterface $childCrud |
||
| 462 | * @param SettingsProviderInterface $provider |
||
| 463 | * @param JsonSchemasInterface $jsonSchemas |
||
| 464 | * @param EncoderInterface $encoder |
||
| 465 | * @param FactoryInterface $errorFactory |
||
| 466 | * @param FormatterFactoryInterface $formatterFactory |
||
| 467 | * @param string $messagesNamespace |
||
| 468 | * @param string $errorMessage |
||
| 469 | * |
||
| 470 | * @return ResponseInterface |
||
| 471 | * |
||
| 472 | * @SuppressWarnings(PHPMD.ExcessiveParameterList) |
||
| 473 | */ |
||
| 474 | 2 | protected static function defaultUpdateInRelationshipHandler( |
|
| 475 | string $parentIndex, |
||
| 476 | string $modelRelName, |
||
| 477 | string $childIndex, |
||
| 478 | UriInterface $requestUri, |
||
| 479 | string $requestBody, |
||
| 480 | string $childSchemaClass, |
||
| 481 | ModelSchemaInfoInterface $schemaInfo, |
||
| 482 | JsonApiDataValidatingParserInterface $childValidator, |
||
| 483 | CrudInterface $parentCrud, |
||
| 484 | CrudInterface $childCrud, |
||
| 485 | SettingsProviderInterface $provider, |
||
| 486 | JsonSchemasInterface $jsonSchemas, |
||
| 487 | EncoderInterface $encoder, |
||
| 488 | FactoryInterface $errorFactory, |
||
| 489 | FormatterFactoryInterface $formatterFactory, |
||
| 490 | string $messagesNamespace = S::GENERIC_NAMESPACE, |
||
| 491 | string $errorMessage = Generic::MSG_ERR_INVALID_ELEMENT |
||
| 492 | ): ResponseInterface { |
||
| 493 | 2 | if ($parentCrud->hasInRelationship($parentIndex, $modelRelName, $childIndex) === true) { |
|
| 494 | 1 | return static::defaultUpdateHandler( |
|
| 495 | 1 | $childIndex, |
|
| 496 | 1 | $requestUri, |
|
| 497 | 1 | $requestBody, |
|
| 498 | 1 | $childSchemaClass, |
|
| 499 | 1 | $schemaInfo, |
|
| 500 | 1 | $childValidator, |
|
| 501 | 1 | $childCrud, |
|
| 502 | 1 | $provider, |
|
| 503 | 1 | $jsonSchemas, |
|
| 504 | 1 | $encoder, |
|
| 505 | 1 | $errorFactory, |
|
| 506 | 1 | $formatterFactory, |
|
| 507 | 1 | $messagesNamespace, |
|
| 508 | 1 | $errorMessage |
|
| 509 | ); |
||
| 510 | } |
||
| 511 | |||
| 512 | 1 | $encParams = null; |
|
| 513 | 1 | $responses = static::defaultCreateResponses($requestUri, $provider, $jsonSchemas, $encoder, $encParams); |
|
| 514 | |||
| 515 | 1 | return $responses->getCodeResponse(404); |
|
| 516 | } |
||
| 517 | |||
| 518 | /** |
||
| 519 | * @param string $index |
||
| 520 | * @param UriInterface $requestUri |
||
| 521 | * @param CrudInterface $crud |
||
| 522 | * @param SettingsProviderInterface $provider |
||
| 523 | * @param JsonSchemasInterface $jsonSchemas |
||
| 524 | * @param EncoderInterface $encoder |
||
| 525 | * |
||
| 526 | * @return ResponseInterface |
||
| 527 | */ |
||
| 528 | 2 | protected static function defaultDeleteHandler( |
|
| 529 | string $index, |
||
| 530 | UriInterface $requestUri, |
||
| 531 | CrudInterface $crud, |
||
| 532 | SettingsProviderInterface $provider, |
||
| 533 | JsonSchemasInterface $jsonSchemas, |
||
| 534 | EncoderInterface $encoder |
||
| 535 | ): ResponseInterface { |
||
| 536 | 2 | $crud->remove($index); |
|
| 537 | |||
| 538 | 2 | $encParams = null; |
|
| 539 | 2 | $responses = static::defaultCreateResponses($requestUri, $provider, $jsonSchemas, $encoder, $encParams); |
|
| 540 | 2 | $response = $responses->getCodeResponse(204); |
|
| 541 | |||
| 542 | 2 | return $response; |
|
| 543 | } |
||
| 544 | |||
| 545 | /** @noinspection PhpTooManyParametersInspection |
||
| 546 | * @param string $parentIndex |
||
| 547 | * @param string $modelRelName |
||
| 548 | * @param string $childIndex |
||
| 549 | * @param UriInterface $requestUri |
||
| 550 | * @param CrudInterface $parentCrud |
||
| 551 | * @param CrudInterface $childCrud |
||
| 552 | * @param SettingsProviderInterface $provider |
||
| 553 | * @param JsonSchemasInterface $jsonSchemas |
||
| 554 | * @param EncoderInterface $encoder |
||
| 555 | * |
||
| 556 | * @return ResponseInterface |
||
| 557 | */ |
||
| 558 | 1 | protected static function defaultDeleteInRelationshipHandler( |
|
| 559 | string $parentIndex, |
||
| 560 | string $modelRelName, |
||
| 561 | string $childIndex, |
||
| 562 | UriInterface $requestUri, |
||
| 563 | CrudInterface $parentCrud, |
||
| 564 | CrudInterface $childCrud, |
||
| 565 | SettingsProviderInterface $provider, |
||
| 566 | JsonSchemasInterface $jsonSchemas, |
||
| 567 | EncoderInterface $encoder |
||
| 568 | ): ResponseInterface { |
||
| 569 | 1 | if ($parentCrud->hasInRelationship($parentIndex, $modelRelName, $childIndex) === true) { |
|
| 570 | 1 | return static::defaultDeleteHandler( |
|
| 571 | 1 | $childIndex, |
|
| 572 | 1 | $requestUri, |
|
| 573 | 1 | $childCrud, |
|
| 574 | 1 | $provider, |
|
| 575 | 1 | $jsonSchemas, |
|
| 576 | 1 | $encoder |
|
| 577 | ); |
||
| 578 | } |
||
| 579 | |||
| 580 | 1 | $encParams = null; |
|
| 581 | 1 | $responses = static::defaultCreateResponses($requestUri, $provider, $jsonSchemas, $encoder, $encParams); |
|
| 582 | |||
| 583 | 1 | return $responses->getCodeResponse(404); |
|
| 584 | } |
||
| 585 | |||
| 586 | /** |
||
| 587 | * @param ContainerInterface $container |
||
| 588 | * @param string $rulesClass |
||
| 589 | * |
||
| 590 | * @return JsonApiQueryValidatingParserInterface |
||
| 591 | * |
||
| 592 | * @throws ContainerExceptionInterface |
||
| 593 | * @throws NotFoundExceptionInterface |
||
| 594 | */ |
||
| 595 | 16 | protected static function defaultCreateQueryParser( |
|
| 607 | |||
| 608 | /** |
||
| 609 | * @param ContainerInterface $container |
||
| 610 | * @param string $rulesClass |
||
| 611 | * |
||
| 612 | * @return JsonApiDataValidatingParserInterface |
||
| 613 | * |
||
| 614 | * @throws ContainerExceptionInterface |
||
| 615 | * @throws NotFoundExceptionInterface |
||
| 616 | */ |
||
| 617 | 8 | protected static function defaultCreateDataParser( |
|
| 629 | |||
| 630 | /** |
||
| 631 | * @param ContainerInterface $container |
||
| 632 | * @param string $schemaClass |
||
| 633 | * |
||
| 634 | * @return ParametersMapperInterface |
||
| 635 | * |
||
| 636 | * @throws ContainerExceptionInterface |
||
| 637 | * @throws NotFoundExceptionInterface |
||
| 638 | */ |
||
| 639 | 16 | protected static function defaultCreateParameterMapper( |
|
| 654 | |||
| 655 | /** |
||
| 656 | * @param JsonApiQueryValidatingParserInterface $queryParser |
||
| 657 | * |
||
| 658 | * @return EncodingParametersInterface |
||
| 659 | */ |
||
| 660 | 14 | protected static function defaultCreateEncodingParameters( |
|
| 668 | |||
| 669 | /** |
||
| 670 | * @param ContainerInterface $container |
||
| 671 | * @param string|null $class |
||
| 672 | * |
||
| 673 | * @return CrudInterface |
||
| 674 | * |
||
| 675 | * @throws ContainerExceptionInterface |
||
| 676 | * @throws NotFoundExceptionInterface |
||
| 677 | */ |
||
| 678 | 26 | protected static function defaultCreateApi(ContainerInterface $container, string $class): CrudInterface |
|
| 688 | |||
| 689 | /** |
||
| 690 | * @param UriInterface $requestUri |
||
| 691 | * @param SettingsProviderInterface $provider |
||
| 692 | * @param JsonSchemasInterface $jsonSchemas |
||
| 693 | * @param EncoderInterface $encoder |
||
| 694 | * @param EncodingParametersInterface|null $parameters |
||
| 695 | * |
||
| 696 | * @return ResponsesInterface |
||
| 697 | */ |
||
| 698 | 21 | protected static function defaultCreateResponses( |
|
| 718 | |||
| 719 | /** |
||
| 720 | * Developers can override the method in order to add/remove some data for `create`/`update` inputs. |
||
| 721 | * |
||
| 722 | * @param string $requestBody |
||
| 723 | * @param FactoryInterface $errorFactory |
||
| 724 | * @param FormatterFactoryInterface $formatterFactory |
||
| 725 | * @param string $messagesNamespace |
||
| 726 | * @param string $errorMessage |
||
| 727 | * |
||
| 728 | * @return array |
||
| 729 | */ |
||
| 730 | 7 | protected static function readJsonFromRequest( |
|
| 747 | |||
| 748 | /** |
||
| 749 | * Developers can override the method in order to use custom data mapping from a Schema to Model. |
||
| 750 | * |
||
| 751 | * @param array $captures |
||
| 752 | * @param string $schemaClass |
||
| 753 | * @param ModelSchemaInfoInterface $schemaInfo |
||
| 754 | * |
||
| 755 | * @return array |
||
| 756 | */ |
||
| 757 | 4 | protected static function mapSchemaDataToModelData( |
|
| 794 | |||
| 795 | /** |
||
| 796 | * @param null|string $value |
||
| 797 | * |
||
| 798 | * @return void |
||
| 799 | */ |
||
| 800 | 26 | private static function assertClassValueDefined(?string $value): void |
|
| 804 | |||
| 805 | /** |
||
| 806 | * @param string $class |
||
| 807 | * @param string $interface |
||
| 808 | * |
||
| 809 | * @return void |
||
| 810 | */ |
||
| 811 | 26 | private static function assertClassImplements(string $class, string $interface): void |
|
| 818 | } |
||
| 819 |
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.