PHP code example of cubicl / php-structure-check

1. Go to this page and download the library: Download cubicl/php-structure-check 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/ */

    

cubicl / php-structure-check example snippets


$    new ObjectType([
        'foo' => new StringType(),
        'bar' => new IntType(),
        'buzz' => new AnyType(),
        'foobar' => new NullableType(new StringType()),
        'nested' => new ObjectType([
            'foobar' => new StringType(),
        ]),
    ])
);

$data = [
    [
        'foo' => 'foe',
        'bar' => 'baz',
        'buzz' => 'foe',
        'foobar' => null,
        'nested' => [
            'foobar' => 'buzz',
        ],
    ], [
        'foo' => 'foe',
        'bar' => 7,
        'buzz' => 'foe',
        'foobar' => 'baz',
        'nested' => [
            'foobar' => 'bozz',
        ],
    ], [
        'foo' => [],
        'bar' => 9.1,
        'foobar' => 'baz',
        'nested' => [
            'foobar' => 'bazz',
        ],
    ],
];

$result = Checker::fulfills($data, $

composer