Skip to content

Commit

Permalink
chore: update the root namespace from Knp to KnpLabs
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine Lelaisant committed Oct 31, 2022
1 parent 095a681 commit 2d7aa96
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 33 deletions.
39 changes: 23 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ A PHP implementation of [JSON Schema](http://json-schema.org/). This library all
Install the latest version with

```bash
$ composer require Knp/php-json-schema
$ composer require knplabs/php-json-schema
```

# Basic Usage

A JsonSchema must implements `Knp\JsonSchema\JsonSchemaInterface` (which is basically an alias for `JsonSerializable`).
A JsonSchema must implements `KnpLabs\JsonSchema\JsonSchemaInterface` (which also extends `JsonSerializable`).

## Default JsonSchema

There is already a default implementation of `JsonSchemaInterface` called `Knp\JsonSchema\JsonSchema` which is an abstract class. This class provides some static methods to create some common JSON Schema scalars or objects.
There is already a default implementation of `JsonSchemaInterface` called `KnpLabs\JsonSchema\JsonSchema` which is an abstract class. This class provides some static methods to create some common JSON Schema scalars or objects.

## Scalars

### `JsonSchema::string()`

```php
use Knp\JsonSchema\JsonSchema;
use KnpLabs\JsonSchema\JsonSchema;

$schema = JsonSchema::create(
'firstName', // The name of the property
Expand All @@ -36,7 +36,7 @@ $schema = JsonSchema::create(
### `JsonSchema::text()`

```php
use Knp\JsonSchema\JsonSchema;
use KnpLabs\JsonSchema\JsonSchema;

$schema = JsonSchema::create(
'content', // The name of the property
Expand All @@ -49,7 +49,7 @@ $schema = JsonSchema::create(
### `JsonSchema::integer()`

```php
use Knp\JsonSchema\JsonSchema;
use KnpLabs\JsonSchema\JsonSchema;

$schema = JsonSchema::create(
'age', // The name of the property
Expand All @@ -62,7 +62,7 @@ $schema = JsonSchema::create(
### `JsonSchema::positiveInteger()`

```php
use Knp\JsonSchema\JsonSchema;
use KnpLabs\JsonSchema\JsonSchema;

$schema = JsonSchema::create(
'age', // The name of the property
Expand All @@ -75,7 +75,7 @@ $schema = JsonSchema::create(
### `JsonSchema::number()`

```php
use Knp\JsonSchema\JsonSchema;
use KnpLabs\JsonSchema\JsonSchema;

$schema = JsonSchema::create(
'price', // The name of the property
Expand All @@ -88,7 +88,7 @@ $schema = JsonSchema::create(
### `JsonSchema::boolean()`

```php
use Knp\JsonSchema\JsonSchema;
use KnpLabs\JsonSchema\JsonSchema;

$schema = JsonSchema::create(
'isAdult', // The name of the property
Expand All @@ -101,7 +101,7 @@ $schema = JsonSchema::create(
### `JsonSchema::date()`

```php
use Knp\JsonSchema\JsonSchema;
use KnpLabs\JsonSchema\JsonSchema;

$schema = JsonSchema::create(
'createdAt', // The name of the property
Expand All @@ -114,14 +114,14 @@ $schema = JsonSchema::create(
## Enum

Enum is a special type of scalar which is a list of possible values.
They can be created by extending the `Knp\JsonSchema\EnumSchema`:
They can be created by extending the `KnpLabs\JsonSchema\EnumSchema`:

```php
<?php

namespace Acme;

use Knp\JsonSchema\EnumSchema;
use KnpLabs\JsonSchema\EnumSchema;

class RoleEnum extends EnumSchema
{
Expand All @@ -148,15 +148,22 @@ class RoleEnum extends EnumSchema

## Objects

You can create objects schema by extending the `Knp\JsonSchema\ObjectSchema` class:
You can create objects schema by extending the `KnpLabs\JsonSchema\ObjectSchema` class:

```php
<?php

namespace Acme;

use Knp\JsonSchema\ObjectSchema;
use KnpLabs\JsonSchema\ObjectSchema;

/**
* @extends ObjectSchema<array{
* firstName: string,
* lastName: string,
* role: string,
* }>
*/
class PersonSchema extends ObjectSchema
{
public function __construct()
Expand Down Expand Up @@ -188,14 +195,14 @@ class PersonSchema extends ObjectSchema

## Collections

You can create collections schema by extending the `Knp\JsonSchema\CollectionSchema` class:
You can create collections schema by extending the `KnpLabs\JsonSchema\CollectionSchema` class:

```php
<?php

namespace Acme;

use Knp\JsonSchema\CollectionSchema;
use KnpLabs\JsonSchema\CollectionSchema;

class PersonCollectionSchema extends CollectionSchema
{
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"autoload": {
"psr-4": {
"Knp\\JsonSchema\\": "src/"
"KnpLabs\\JsonSchema\\": "src/"
}
},
"authors": [
Expand Down
2 changes: 1 addition & 1 deletion src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Knp\JsonSchema;
namespace KnpLabs\JsonSchema;

use Exception;

Expand Down
2 changes: 1 addition & 1 deletion src/CollectionSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Knp\JsonSchema;
namespace KnpLabs\JsonSchema;

/**
* @template I
Expand Down
2 changes: 1 addition & 1 deletion src/EnumSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Knp\JsonSchema;
namespace KnpLabs\JsonSchema;

/**
* @template E
Expand Down
4 changes: 1 addition & 3 deletions src/JsonSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

declare(strict_types=1);

namespace Knp\JsonSchema;

use Knp\JsonSchema\Validator\Errors;
namespace KnpLabs\JsonSchema;

/**
* @template T of mixed
Expand Down
3 changes: 1 addition & 2 deletions src/JsonSchemaInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

declare(strict_types=1);

namespace Knp\JsonSchema;
namespace KnpLabs\JsonSchema;

use JsonSerializable;
use Knp\JsonSchema\Validator\Errors;

/**
* @template T
Expand Down
2 changes: 1 addition & 1 deletion src/ObjectSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Knp\JsonSchema;
namespace KnpLabs\JsonSchema;

/**
* @template T
Expand Down
6 changes: 3 additions & 3 deletions src/Scalar/UuidSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types=1);

namespace Knp\JsonSchema\Scalar;
namespace KnpLabs\JsonSchema\Scalar;

use Knp\JsonSchema\JsonSchema;
use Knp\JsonSchema\JsonSchemaInterface;
use KnpLabs\JsonSchema\JsonSchema;
use KnpLabs\JsonSchema\JsonSchemaInterface;

/**
* @implements JsonSchemaInterface<string>
Expand Down
4 changes: 2 additions & 2 deletions src/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace Knp\JsonSchema;
namespace KnpLabs\JsonSchema;

use Knp\JsonSchema\Validator\Errors;
use KnpLabs\JsonSchema\Validator\Errors;

interface Validator
{
Expand Down
2 changes: 1 addition & 1 deletion src/Validator/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Knp\JsonSchema\Validator;
namespace KnpLabs\JsonSchema\Validator;

final class Error
{
Expand Down
2 changes: 1 addition & 1 deletion src/Validator/Errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Knp\JsonSchema\Validator;
namespace KnpLabs\JsonSchema\Validator;

use ArrayIterator;
use Countable;
Expand Down

0 comments on commit 2d7aa96

Please sign in to comment.