\LazyJsonMapper\ExportClassAnalysis

Container for the result of a LazyJsonMapper class analysis.

Describes any problems (bad/missing definitions) of a LazyJsonMapper class property map versus its actual object instance's JSON data.

NOTE: The class validates all parameters, but provides public properties to avoid needless function calls. It's therefore your responsibility to never assign any bad values to the public properties after this object's creation!

Summary

Methods
Properties
Constants
mergeAnalysis()
addProblem()
sortProblemLists()
hasProblems()
generateNiceSummaries()
generateNiceSummariesAsString()
$bad_definitions
$missing_definitions
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$bad_definitions

$bad_definitions : array<mixed,array>

Associative array of class names and problems with their class property maps.

Bad definitions that failed to construct or whose types cannot be coerced as-requested or whose JSON data doesn't match the definition, such as a mismatch with the array-depth of the actual data.

Type

array<mixed,array>

$missing_definitions

$missing_definitions : array<mixed,array>

Associative array of class names and what JSON properties they are missing.

Undefined properties that don't exist in the class property map, but which exist in the object instance's JSON data.

Type

array<mixed,array>

Methods

mergeAnalysis()

mergeAnalysis(\LazyJsonMapper\Export\ClassAnalysis  $other) 

Merge another ClassAnalysis object's result into this instance.

Parameters

\LazyJsonMapper\Export\ClassAnalysis $other

The other object instance.

addProblem()

addProblem(string  $definitionSource, string  $problemType, string  $problemMessage) 

Adds a problem description to the internal state.

Parameters

string $definitionSource

The class which has the problem.

string $problemType

Type of problem. Either bad_definitions or missing_definitions.

string $problemMessage

A message describing the actual problem.

Throws

\LazyJsonMapper\Exception\LazyJsonMapperException

If any of the parameters are invalid.

sortProblemLists()

sortProblemLists() 

Convert the per-class arrays to sorted lists of missing/bad properties.

Removes all duplicate messages and sorts everything nicely. It is recommended to only call this function a single time, on the final ClassAnalysis object (after all other steps are finished).

hasProblems()

hasProblems() : boolean

Check whether any problems were discovered.

In that case, it's recommended to use generateNiceSummaries() to format user-readable messages about the problems.

Returns

boolean

generateNiceSummaries()

generateNiceSummaries() : array

Generates nicely formatted problem summaries for this class analysis.

Returns

array —

An array with formatted messages for every type of analysis which actually had errors, keyed by the problem type. If no errors, the returned array will be empty.

generateNiceSummariesAsString()

generateNiceSummariesAsString() : string

Generates a nicely formatted problem summary string for this class analysis.

This helper combines all summaries and returns them as a single string (rather than as an array), which is very useful when displaying ALL errors to a user as a message.

Returns

string —

The final string. Is an empty string if no errors exist.