diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 14206b4..e9d271d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -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" diff --git a/src/DataModel.php b/src/DataModel.php index fdf8f48..e302874 100644 --- a/src/DataModel.php +++ b/src/DataModel.php @@ -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 { @@ -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); diff --git a/src/FromJson.php b/src/FromJson.php index c2019fb..a2338ce 100644 --- a/src/FromJson.php +++ b/src/FromJson.php @@ -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 {