Skip to content

Commit

Permalink
prepare to v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
indianmodassir committed Nov 21, 2024
1 parent c1b9a89 commit e682ee5
Show file tree
Hide file tree
Showing 9 changed files with 419 additions and 30 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# PHP Data
Data is a lightweight PHP library for simplifying string, array, and object manipulation with intuitive methods.

<a href="https://github.com/shahzadamodassir"><img src="https://img.shields.io/badge/Author-Shahzada%20Modassir-%2344cc11?style=flat-square"/></a>
<a href="LICENSE"><img src="https://img.shields.io/github/license/lazervel/data?style=flat-square"/></a>
<a href="https://packagist.org/packages/container/data"><img src="https://img.shields.io/packagist/dt/container/data.svg?style=flat-square" alt="Total Downloads"></a>
<a href="https://github.com/lazervel/data/stargazers"><img src="https://img.shields.io/github/stars/lazervel/data?style=flat-square"/></a>
<a href="https://github.com/lazervel/data/releases"><img src="https://img.shields.io/github/release/lazervel/data.svg?style=flat-square" alt="Latest Version"></a>
<a href="https://github.com/lazervel/data/graphs/contributors"><img src="https://img.shields.io/github/contributors/lazervel/data?style=flat-square" alt="Contributors"></a>
<a href="/"><img src="https://img.shields.io/github/repo-size/lazervel/data?style=flat-square" alt="Repository Size"></a>


## Resources
- [Report issue](https://github.com/lazervel/data/issues) and [send Pull Request](https://github.com/lazervel/data/pulls) in the [main Lazervel repository](https://github.com/lazervel/data)
6 changes: 4 additions & 2 deletions src/Base/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Container\Data\Base;

use Container\Data\Exception\RTException;

/**
* @internal
*/
Expand All @@ -18,7 +20,7 @@ abstract class Base
/**
* Returns The CustomManipulator instance with previous or initial value.
*
* @return \Data\Custom\CustomManipulatorInterface
* @return \Container\Data\Custom\CustomManipulatorInterface
*/
abstract public function prevWith();

Expand Down Expand Up @@ -160,7 +162,7 @@ public function __toString()
private static function throwIfFunctionNotExists(string $func) : void
{
if (!\function_exists($func)) {
throw new RTException(\sprintf('Unable to perform data operation because the "%s()" function has been disabled.'), $func);
throw new RTException(\sprintf('Unable to perform data operation because the "%s()" function has been disabled.', $func));
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/Custom/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
trait Compiler
{
/**
*
* Register all Manipulators with name, It's used to Compiling Manipulator
*
* @var array<string,string> $MANIPULATORS
*/
Expand All @@ -36,9 +36,11 @@ trait Compiler
];

/**
* Check array associative or none-associative of given $array, If $array is
* associative then return true, Otherwise false
*
* @param array $array [required]
* @return bool
* @return bool If array assoc return true, Otherwise false
*/
private function isAssoc(array $array) : bool
{
Expand All @@ -47,10 +49,10 @@ private function isAssoc(array $array) : bool
}

/**
*
* Compiling the given $value and Returns a matched Manipulator instance
*
* @param mixed $value [required]
* @return \Data\Custom\CustomManipulatorInterface
* @return \Container\Data\Custom\CustomManipulatorInterface
*/
private function doCompile($value)
{
Expand Down
11 changes: 6 additions & 5 deletions src/Custom/CustomManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public function __construct($value) {
/**
* Returns The CustomManipulator instance with the current or lastes value.
*
* @return \Data\Custom\CustomManipulatorInterface
* @param mixed $value [required]
* @return \Container\Data\Custom\CustomManipulatorInterface
*/
public function return($value)
{
Expand All @@ -53,7 +54,7 @@ public function prev()
/**
* Returns The CustomManipulator instance with previous or initial value.
*
* @return \Data\Custom\CustomManipulatorInterface
* @return \Container\Data\Custom\CustomManipulatorInterface
*/
public function prevWith()
{
Expand All @@ -64,7 +65,7 @@ public function prevWith()
* Returns The CustomManipulator instance with override value.
*
* @param mixed $value [required]
* @return \Data\Custom\CustomManipulatorInterface
* @return \Container\Data\Custom\CustomManipulatorInterface
*/
public function override($value)
{
Expand All @@ -87,7 +88,7 @@ public static function create($value)
/**
* Returns The CustomManipulator instance compile with current value.
*
* @return \Data\Custom\CustomManipulatorInterface
* @return \Container\Data\Custom\CustomManipulatorInterface
*/
public function compile()
{
Expand All @@ -105,7 +106,7 @@ public function compile()
* @param string $name [required]
* @param array $arguments [optional]
*
* @throws \Data\Exception\MethodNotFoundException When trying to access private or undefined method.
* @throws \Container\Data\Exception\MethodNotFoundException When trying to access private or undefined method.
*/
public function __call($name, $arguments) : void
{
Expand Down
13 changes: 9 additions & 4 deletions src/Custom/CustomManipulatorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,32 @@
interface CustomManipulatorInterface
{
/**
* Returns The CustomManipulator instance with the current or lastes value.
*
* @param mixed $value [required]
* @return
* @return \Container\Data\Custom\CustomManipulatorInterface
*/
public function return($value);

/**
* Returns The CustomManipulator instance with previous or initial value.
*
* @return
* @return \Container\Data\Custom\CustomManipulatorInterface
*/
public function prevWith();

/**
* Returns The CustomManipulator instance compile with current value.
*
* @return
* @return \Container\Data\Custom\CustomManipulatorInterface
*/
public function compile();

/**
* Returns The CustomManipulator instance with override value.
*
* @param mixed $value [required]
* @return
* @return \Container\Data\Custom\CustomManipulatorInterface
*/
public function override($value);
}
Expand Down
52 changes: 48 additions & 4 deletions src/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,52 @@

/**
* Data PHP library for simplifying string, array, and object manipulation with intuitive methods.
*
* The (data) Github repository
* @see https://github.com/lazervel/data
*
* @author Shahzada Modassir <shahzadamodassir@gmail.com>
* @author Shahzadi Afsara <shahzadiafsara@gmail.com>
*
* @copyright (c) Shahzada Modassir
* @copyright (c) Shahzadi Afsara
*
* @license MIT License
* @see https://github.com/lazervel/data/blob/main/LICENSE
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Container\Data;

use Container\Data\Custom\CustomManipulator;
use Container\Data\Base\Base;

/**
* Data PHP library for simplifying string, array, and object manipulation with intuitive methods.
*
* @author Shahzada Modassir <shahzadamodassir@gmail.com>
* @see https://github.com/lazervel/data
*/
class Data extends Base
{
/**
* Store the current latest value.
*
* @var mixed
*/
protected $value;

/**
* Store the previous or Initial value.
*
* @var mixed
*/
private $prev;

/**
* Creates a new Data constructor.
* Initializes a new instance of [Data] with the given value.
*
* @param mixed $value [required]
* @return void
Expand All @@ -39,38 +72,49 @@ public function prev()
}

/**
* Returns The CustomManipulator instance with previous or initial value.
*
* @param mixed $value [required]
* @return \Data\Custom\CustomManipulatorInterface
* @return \Container\Data\Custom\CustomManipulatorInterface
*/
public function prevWith()
{
return $this->with($this->prev);
}

/**
* Create a new CustomManipulator instance with the given value.
*
* @param mixed $value [required]
* @return \Data\Custom\CustomManipulatorInterface
* @return \Container\Data\Custom\CustomManipulatorInterface
*/
public static function with($value)
{
return CustomManipulator::create($value)->compile();
}

/**
* Magic method __get is called when trying to access a non-existing or inaccessible property.
*
* @param string $property [required]
* @return mixed The value of the property if it exists in the $data array,
* or a message indicating that the property is not found.
*/
public function __get($property)
{
return $this->with($this->value)->$property;
}

/**
* Magic method __call is called when trying to invoke a non-existing or inaccessible method.
*
* @param string $name [required]
* @param array $arguments [optional]
*
* @throws \Data\Exception\MethodNotFoundException When trying to access private or undefined method.
* @throws \Container\Data\Exception\MethodNotFoundException When trying to access private or undef method.
*
* @return mixed The Manipulated data value.
* @return mixed The Manipulated data value,
* A message or value based on the requested method.
*/
public function __call($name, $arguments)
{
Expand Down
Loading

0 comments on commit e682ee5

Please sign in to comment.