Skip to content

Commit

Permalink
Update manual
Browse files Browse the repository at this point in the history
  • Loading branch information
kamshory committed Oct 4, 2024
1 parent cfe628e commit a36263a
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 1 deletion.
36 changes: 35 additions & 1 deletion manual/includes/_simple-object.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

```
<?php
use MagicObject\MagicObject;
Expand All @@ -117,6 +122,16 @@ $someObject->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;
```

Expand All @@ -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

```
<?php
use MagicObject\MagicObject;
Expand Down Expand Up @@ -188,18 +208,32 @@ $someObject->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";
```
Expand All @@ -222,4 +256,4 @@ After Pop
3
After Pop
{"data":["Text 1","Text 2"]}
```
```
33 changes: 33 additions & 0 deletions manual/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ <h3>Check if Properties has Value</h3>
error_log($someObject);</code></pre>
<h3>Push</h3>
<p>Push is present in MagicObject version 1.22. Push is used to add array elements from a MagicObject property. The <code>push</code> method basically uses the <code>array_push</code> function which is a built-in PHP function.</p>
<p>As with the <code>set</code> method, users can use the <code>push</code> method in two ways:</p>
<ol>
<li>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.</li>
<li>using two parameters, namely the property name written in camelcase style and the value of the element to be added</li>
</ol>
<pre><code>&lt;?php
use MagicObject\MagicObject;

Expand All @@ -132,11 +137,26 @@ <h3>Push</h3>
$someObject-&gt;pushData(4.0);
$someObject-&gt;pushData(true);

/*
or

$someObject-&gt;push("data", "Text 1");
$someObject-&gt;push("data", "Text 2");
$someObject-&gt;push("data", 3);
$someObject-&gt;push("data", 4.1);
$someObject-&gt;push("data", true);
*/

echo $someObject;</code></pre>
<p>Output will be</p>
<pre><code class="language-json">{"data":["Text 1","Text 2",3,4.1,true]}</code></pre>
<h3>Pop</h3>
<p>Pop is present in MagicObject version 1.22. Pop is used to remove the last element of an array from a MagicObject property. The <code>pop</code> method basically uses the <code>array_pop</code> function which is a built-in PHP function.</p>
<p>As with the <code>unset</code> method, users can use the <code>pop</code> method in two ways:</p>
<ol>
<li>using a subfix in the form of a property name written in camelcase style.</li>
<li>using one parameter, namely the property name</li>
</ol>
<pre><code>&lt;?php
use MagicObject\MagicObject;

Expand Down Expand Up @@ -185,18 +205,31 @@ <h3>Pop</h3>
$someObject-&gt;pushData(4.1);
$someObject-&gt;pushData(true);

/*
or

$someObject-&gt;push("data", "Text 1");
$someObject-&gt;push("data", "Text 2");
$someObject-&gt;push("data", 3);
$someObject-&gt;push("data", 4.1);
$someObject-&gt;push("data", true);
*/

echo "After Push\r\n";

echo $someObject."\r\n\r\n";

echo "Pop\r\n";
echo $someObject-&gt;popData()."\r\n";
// or echo $someObject-&gt;pop("data")."\r\n";
echo "After Pop\r\n";
echo $someObject."\r\n\r\n";
echo $someObject-&gt;popData()."\r\n";
// or echo $someObject-&gt;pop("data")."\r\n";
echo "After Pop\r\n";
echo $someObject."\r\n\r\n";
echo $someObject-&gt;popData()."\r\n";
// or echo $someObject-&gt;pop("data")."\r\n";
echo "After Pop\r\n";
echo $someObject."\r\n\r\n";</code></pre>
<p>Output will be:</p>
Expand Down
35 changes: 35 additions & 0 deletions tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

```
<?php
use MagicObject\MagicObject;
Expand All @@ -145,6 +150,16 @@ $someObject->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;
```

Expand All @@ -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

```
<?php
use MagicObject\MagicObject;
Expand Down Expand Up @@ -216,18 +236,32 @@ $someObject->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";
```
Expand All @@ -251,6 +285,7 @@ After Pop
After Pop
{"data":["Text 1","Text 2"]}
```

## Extends MagicObject

User can extend `MagicObject` to many classes.
Expand Down

0 comments on commit a36263a

Please sign in to comment.