Skip to content

Commit

Permalink
Update DocBlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
david_smith committed Sep 3, 2024
1 parent f570d80 commit b015f55
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
9 changes: 2 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "composer" # See documentation for possible values
directory: "/" # Location of package manifests
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
15 changes: 12 additions & 3 deletions src/DataModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ trait DataModel
* Instantiates the class from an array, string, or object, casting values based on PHPDoc annotations.
* Uses reflection to match data with property types, supporting primitives and classes with a `from` method.
*
* @param array|string|object $value Data to populate class properties.
* Example:
* ```
* MyClass::from(['name' => 'John Doe']);
* MyClass::from($stdClass);
* ```
*
* @param iterable|object|null $value Data to populate class properties.
*/
public static function from($value = null): self
{
Expand Down Expand Up @@ -71,9 +77,12 @@ public static function from($value = null): self
continue;
}

/* Prepend the current namespace */
/**
* Prepend the current namespace
*
* @var DataModel $fqns
*/
$fqns = "{$ReflectionClass->getNamespaceName()}\\{$matches[Str::type]}";
/* Class with a 'from' method exits. */
if (method_exists($fqns, Str::from)) {
$self->{$property} = $fqns::from($val);

Expand Down
11 changes: 8 additions & 3 deletions src/FromJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ trait FromJson
* Instantiates the class from a JSON string by decoding it into an associative array
* and mapping the array to class properties using the `from` method.
*
* @param string $value JSON string to decode.
* @param int $depth Maximum decoding depth (default: 512).
* @param int $flags JSON decode options (default: 0).
* Example
* ```
* MyClass::fromJson('{"json": 1}');
* ```
*
* @param string $value JSON string to decode.
* @param int $depth Maximum decoding depth (default: 512).
* @param int $flags JSON decode options (default: 0).
*/
public static function fromJson(string $value, int $depth = 512, int $flags = 0): self
{
Expand Down

0 comments on commit b015f55

Please sign in to comment.