PHP code example of yoanm / jsonrpc-params-symfony-constraint-doc-sdk

1. Go to this page and download the library: Download yoanm/jsonrpc-params-symfony-constraint-doc-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yoanm / jsonrpc-params-symfony-constraint-doc-sdk example snippets


use Yoanm\JsonRpcParamsSymfonyConstraintDoc\App\Helper\ConstraintPayloadDocHelper;
use Yoanm\JsonRpcParamsSymfonyConstraintDoc\App\Helper\DocTypeHelper;
use Yoanm\JsonRpcParamsSymfonyConstraintDoc\App\Helper\MinMaxHelper;
use Yoanm\JsonRpcParamsSymfonyConstraintDoc\App\Helper\StringDocHelper;
use Yoanm\JsonRpcParamsSymfonyConstraintDoc\App\Helper\TypeGuesser;
use Yoanm\JsonRpcParamsSymfonyConstraintDoc\Infra\Transformer\ConstraintToParamsDocTransformer;

$constraintPayloadDocHelper = new ConstraintPayloadDocHelper();

$transformer = new ConstraintToParamsDocTransformer(
  new DocTypeHelper(
    $constraintPayloadDocHelper,
    new TypeGuesser()
  ),
  new StringDocHelper(),
  new MinMaxHelper(),
  $constraintPayloadDocHelper
);

use Symfony\Component\Validator\Constraints as ConstraintNS;
use Yoanm\JsonRpcServerDoc\Domain\Model\Type\ObjectDoc;
use Yoanm\JsonRpcServerDoc\Domain\Model\Type\StringDoc;

$constraint = new ConstraintNS\Collection([
  'a' => new ConstraintNS\Type('string'),
  'b' => new ConstraintNS\Type('integer'),
  'c' => new ConstraintNS\Type('bool')
]);

/** @var ObjectDoc $constraintDoc */
$constraintDoc = $transformer->transform($constraint);

/** @var StringDoc $constraintDoc2 */
$constraintDoc2 = $transformer->transformList([
  new ConstraintNS\Type('string'),
  new ConstraintNS\NotNull()
]);