diff --git a/manual/includes/_simple-object.md b/manual/includes/_simple-object.md index 50fd828..38eb550 100644 --- a/manual/includes/_simple-object.md +++ b/manual/includes/_simple-object.md @@ -103,6 +103,11 @@ error_log($someObject); Push is present in MagicObject version 1.22. Push is used to add array elements from a MagicObject property. The `push` method basically uses the `array_push` function which is a built-in PHP function. +As with the `set` method, users can use the `push` method in two ways: + +1. using a subfix in the form of a property name written in camelcase style with one parameter, namely the value of the element to be added. +2. using two parameters, namely the property name written in camelcase style and the value of the element to be added + ``` pushData(3); $someObject->pushData(4.0); $someObject->pushData(true); +/* +or + +$someObject->push("data", "Text 1"); +$someObject->push("data", "Text 2"); +$someObject->push("data", 3); +$someObject->push("data", 4.1); +$someObject->push("data", true); +*/ + echo $someObject; ``` @@ -130,6 +145,11 @@ Output will be Pop is present in MagicObject version 1.22. Pop is used to remove the last element of an array from a MagicObject property. The `pop` method basically uses the `array_pop` function which is a built-in PHP function. +As with the `unset` method, users can use the `pop` method in two ways: + +1. using a subfix in the form of a property name written in camelcase style. +2. using one parameter, namely the property name + ``` pushData(3); $someObject->pushData(4.1); $someObject->pushData(true); +/* +or + +$someObject->push("data", "Text 1"); +$someObject->push("data", "Text 2"); +$someObject->push("data", 3); +$someObject->push("data", 4.1); +$someObject->push("data", true); +*/ + + echo "After Push\r\n"; echo $someObject."\r\n\r\n"; echo "Pop\r\n"; echo $someObject->popData()."\r\n"; +// or echo $someObject->pop("data")."\r\n"; echo "After Pop\r\n"; echo $someObject."\r\n\r\n"; echo $someObject->popData()."\r\n"; +// or echo $someObject->pop("data")."\r\n"; echo "After Pop\r\n"; echo $someObject."\r\n\r\n"; echo $someObject->popData()."\r\n"; +// or echo $someObject->pop("data")."\r\n"; echo "After Pop\r\n"; echo $someObject."\r\n\r\n"; ``` @@ -222,4 +256,4 @@ After Pop 3 After Pop {"data":["Text 1","Text 2"]} -``` \ No newline at end of file +``` diff --git a/manual/index.html b/manual/index.html index e6de357..d059efa 100644 --- a/manual/index.html +++ b/manual/index.html @@ -119,6 +119,11 @@
Push is present in MagicObject version 1.22. Push is used to add array elements from a MagicObject property. The push
method basically uses the array_push
function which is a built-in PHP function.
As with the set
method, users can use the push
method in two ways:
<?php
use MagicObject\MagicObject;
@@ -132,11 +137,26 @@ Push
$someObject->pushData(4.0);
$someObject->pushData(true);
+/*
+or
+
+$someObject->push("data", "Text 1");
+$someObject->push("data", "Text 2");
+$someObject->push("data", 3);
+$someObject->push("data", 4.1);
+$someObject->push("data", true);
+*/
+
echo $someObject;
Output will be
{"data":["Text 1","Text 2",3,4.1,true]}
Pop is present in MagicObject version 1.22. Pop is used to remove the last element of an array from a MagicObject property. The pop
method basically uses the array_pop
function which is a built-in PHP function.
As with the unset
method, users can use the pop
method in two ways:
<?php
use MagicObject\MagicObject;
@@ -185,18 +205,31 @@ Pop
$someObject->pushData(4.1);
$someObject->pushData(true);
+/*
+or
+
+$someObject->push("data", "Text 1");
+$someObject->push("data", "Text 2");
+$someObject->push("data", 3);
+$someObject->push("data", 4.1);
+$someObject->push("data", true);
+*/
+
echo "After Push\r\n";
echo $someObject."\r\n\r\n";
echo "Pop\r\n";
echo $someObject->popData()."\r\n";
+// or echo $someObject->pop("data")."\r\n";
echo "After Pop\r\n";
echo $someObject."\r\n\r\n";
echo $someObject->popData()."\r\n";
+// or echo $someObject->pop("data")."\r\n";
echo "After Pop\r\n";
echo $someObject."\r\n\r\n";
echo $someObject->popData()."\r\n";
+// or echo $someObject->pop("data")."\r\n";
echo "After Pop\r\n";
echo $someObject."\r\n\r\n";
Output will be:
diff --git a/tutorial.md b/tutorial.md index efbe966..5bd7e51 100644 --- a/tutorial.md +++ b/tutorial.md @@ -131,6 +131,11 @@ error_log($someObject); Push is present in MagicObject version 1.22. Push is used to add array elements from a MagicObject property. The `push` method basically uses the `array_push` function which is a built-in PHP function. +As with the `set` method, users can use the `push` method in two ways: + +1. using a subfix in the form of a property name written in camelcase style with one parameter, namely the value of the element to be added. +2. using two parameters, namely the property name written in camelcase style and the value of the element to be added + ``` pushData(3); $someObject->pushData(4.0); $someObject->pushData(true); +/* +or + +$someObject->push("data", "Text 1"); +$someObject->push("data", "Text 2"); +$someObject->push("data", 3); +$someObject->push("data", 4.1); +$someObject->push("data", true); +*/ + echo $someObject; ``` @@ -158,6 +173,11 @@ Output will be Pop is present in MagicObject version 1.22. Pop is used to remove the last element of an array from a MagicObject property. The `pop` method basically uses the `array_pop` function which is a built-in PHP function. +As with the `unset` method, users can use the `pop` method in two ways: + +1. using a subfix in the form of a property name written in camelcase style. +2. using one parameter, namely the property name + ``` pushData(3); $someObject->pushData(4.1); $someObject->pushData(true); +/* +or + +$someObject->push("data", "Text 1"); +$someObject->push("data", "Text 2"); +$someObject->push("data", 3); +$someObject->push("data", 4.1); +$someObject->push("data", true); +*/ + + echo "After Push\r\n"; echo $someObject."\r\n\r\n"; echo "Pop\r\n"; echo $someObject->popData()."\r\n"; +// or echo $someObject->pop("data")."\r\n"; echo "After Pop\r\n"; echo $someObject."\r\n\r\n"; echo $someObject->popData()."\r\n"; +// or echo $someObject->pop("data")."\r\n"; echo "After Pop\r\n"; echo $someObject."\r\n\r\n"; echo $someObject->popData()."\r\n"; +// or echo $someObject->pop("data")."\r\n"; echo "After Pop\r\n"; echo $someObject."\r\n\r\n"; ``` @@ -251,6 +285,7 @@ After Pop After Pop {"data":["Text 1","Text 2"]} ``` + ## Extends MagicObject User can extend `MagicObject` to many classes.