diff --git a/README.md b/README.md index f11e0c4..4b3c15d 100644 --- a/README.md +++ b/README.md @@ -463,6 +463,40 @@ try { } ``` +# Conclusion + + +MagicObject is designed to offer ease and speed in creating and managing database entities. Here are several reasons why the methods used by MagicObject can be considered intuitive: + +1. **Declarative and Annotation-Based**: + + - By using annotations, MagicObject allows developers to declare entity properties and metadata directly within the code. This makes it easier to understand the structure and relationships of the entities. + +2. **Easy Integration with Configuration**: + + - MagicObject can be easily integrated with configuration systems like ConfigApp, making database and development environment setup more straightforward and organized. + +3. **Automation**: + + - MagicObject automatically handles many routine tasks, such as CRUD (Create, Read, Update, Delete) operations and table relationships. Developers don’t need to write manual SQL code, reducing the potential for errors. + +4. **Object-Oriented Approach**: + + - MagicObject uses an object-oriented approach, allowing developers to work with entities as PHP objects, utilizing methods and properties directly on the entities. + +5. **Support for Various Data Formats**: + + - MagicObject can accept data in various formats, including stdClass objects, associative arrays, and form inputs from HTML. This provides flexibility in handling data from different sources. + +6. **Easy Relationship Management**: + + - By defining relationships between entities, such as `ManyToOne` and `OneToMany`, MagicObject makes it easy to manage complex relationships without needing to write explicit join SQL. + +7. **Automatic Conversion Capabilities**: + + - MagicObject has the capability to automatically convert objects to JSON, which is extremely useful for APIs and modern web applications. + + # Tutorial A tutorial is available here: https://github.com/Planetbiru/MagicObject/blob/main/tutorial.md diff --git a/src/Util/AttrUtil.php b/src/Util/AttrUtil.php index 93dcc3f..90bcced 100644 --- a/src/Util/AttrUtil.php +++ b/src/Util/AttrUtil.php @@ -33,6 +33,7 @@ private function __construct() * * Example: * ```php + * dmsToDd(34, 15, 30); * echo $dms->printDd(); // Outputs: 34.258333 @@ -82,6 +83,7 @@ public function dmsToDd($deg, $min, $sec) * * Example: * ```php + * ddToDms(34.258333); * echo $dms->printDms(); // Outputs: 34:15:30 diff --git a/src/Util/PicoArrayUtil.php b/src/Util/PicoArrayUtil.php index d2ad28c..bb9cf81 100644 --- a/src/Util/PicoArrayUtil.php +++ b/src/Util/PicoArrayUtil.php @@ -31,6 +31,7 @@ private function __construct() * * Example: * ```php + * 'John', 'last_name' => 'Doe']; * $camelized = PicoArrayUtil::camelize($data); * // $camelized is ['firstName' => 'John', 'lastName' => 'Doe'] @@ -58,6 +59,7 @@ public static function camelize($input) * * Example: * ```php + * 'John', 'lastName' => 'Doe']; * $snakeized = PicoArrayUtil::snakeize($data); * // $snakeized is ['first_name' => 'John', 'last_name' => 'Doe'] diff --git a/src/Util/PicoGenericObject.php b/src/Util/PicoGenericObject.php index c7fc8f2..e228061 100644 --- a/src/Util/PicoGenericObject.php +++ b/src/Util/PicoGenericObject.php @@ -43,6 +43,7 @@ public function __construct($data = null) * * Example: * ```php + * loadData(['first_name' => 'John', 'last_name' => 'Doe']); * echo $obj->get('firstName'); // Outputs: John @@ -70,6 +71,7 @@ public function loadData($data) * * Example: * ```php + * set('first_name', 'John'); * echo $obj->get('firstName'); // Outputs: John @@ -93,6 +95,7 @@ public function set($propertyName, $propertyValue) * * Example: * ```php + * get('firstName'); // Retrieves the value of 'firstName' * ``` * @@ -112,6 +115,7 @@ public function get($propertyName) * * Example: * ```php + * firstName = 'John'; // Calls __set() internally * ``` * @@ -131,6 +135,7 @@ public function __set($name, $value) * * Example: * ```php + * firstName; // Calls __get() internally * ``` * @@ -150,6 +155,7 @@ public function __get($name) * * Example: * ```php + * issetFirstName()) { * // Do something * } @@ -168,6 +174,7 @@ public function __isset($name) * * Example: * ```php + * unsetFirstName(); // Removes the property 'firstName' * ``` * diff --git a/src/Util/PicoStringUtil.php b/src/Util/PicoStringUtil.php index 5ea6fd8..63fde79 100644 --- a/src/Util/PicoStringUtil.php +++ b/src/Util/PicoStringUtil.php @@ -15,6 +15,7 @@ * * Example usage: * ``` + * 'John', 'age' => 30]; * $yaml = PicoYamlUtil::dump($data, null, 4, 0); * ```