PHPackages                             sintese/phancackes - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. sintese/phancackes

ActiveLibrary

sintese/phancackes
==================

v0.4.0(1y ago)01MITPHPPHP ^7.4

Since Jul 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/realfabecker/phancakes)[ Packagist](https://packagist.org/packages/sintese/phancackes)[ RSS](/packages/sintese-phancackes/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

Phancakes
=========

[](#phancakes)

Case study for Tabulation and Expansion of objects built from a [json-schema](https://json-schema.org/).

[![Latest Stable Version](https://camo.githubusercontent.com/460e501bef8ff5989f7ac2b1cfa7dbb9c4822de13328489edb339084655d0d41/68747470733a2f2f706f7365722e707567782e6f72672f73696e746573652f7068616e6361636b65732f76657273696f6e2e737667)](https://packagist.org/packages/sintese/phancackes)[![Security Rating](https://camo.githubusercontent.com/57b2e78afee72a9abeb68dc7cda95a060047a9ff41e36b678d437ddc0ce73655/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d7265616c66616265636b65725f7068616e63616b6573266d65747269633d73656375726974795f726174696e67)](https://sonarcloud.io/summary/new_code?id=realfabecker_phancakes)

Usage
=====

[](#usage)

Given the definition of an object specified by a [json-schema](https://json-schema.org/):

```
$schema = flat(new SchemaObject($schema));
```

The tabulated structure will compose key (path) and value (definition) at the same level:

```
{
  "$.productId": {
    "description": "The unique identifier for a product",
    "type": "integer",
    "path": "$.productId",
    "prop": "productId"
  },
  "$.dimensions.width": {
    "type": "number",
    "path": "$.dimensions.width",
    "prop": "width"
  },
  "$.dimensions.height": {
    "type": "number",
    "path": "$.dimensions.height",
    "prop": "height"
  },
  "$.tags[0].name": {
    "type": "string",
    "path": "$.tags[0].name",
    "prop": "name"
  }
}
```

Having the tabulated structure in hand, we can create a flattened object to simplify its storage:

```
$payload =
