diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..6f3a2913 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index b8bb2822..3377e3a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1391,3 +1391,25 @@ This provides a **persistent session storage** mechanism using **SQLite** as the * **Lightweight:** Suitable for shared hosting or small applications. * **Reliability:** Prevents session loss when PHP restarts, unlike file-based sessions. +# MagicObject Version 3.20.0 + +## Change: Removal of Math-Related Classes + +In this release, several math-related classes have been **removed** from MagicObject to keep the core library lightweight and focused. + +### Removed Modules + +1. Complex Numbers +2. Matrix Operations +3. Geometry Utilities + +### Migration + +These classes are **not discontinued**, but have been moved into a **new dedicated repository**: + +👉 [Planetbiru/Math](https://github.com/Planetbiru/Math) + +Developers who rely on these math utilities should install the new package separately: + +```bash +composer require planetbiru/math diff --git a/docs/doc.html b/docs/doc.html index dbae144d..863fb7b9 100644 --- a/docs/doc.html +++ b/docs/doc.html @@ -11,7 +11,7 @@
ComplexNumber class
-Real part of the complex number.
-Imaginary part of the complex number.
-Constructor to initialize the complex number.
-Real part of the complex number.
Imaginary part of the complex number.
Add another complex number to this one.
-The complex number to add.
The sum of the two complex numbers.
Subtract another complex number from this one.
-The complex number to subtract.
The result of the subtraction.
Multiply this complex number by another.
-The complex number to multiply.
The product of the two complex numbers.
Divide this complex number by another.
-The complex number to divide by.
The result of the division.
Get the magnitude of the complex number.
-The magnitude of the complex number.
Get the conjugate of the complex number.
-The conjugate of the complex number.
String representation of the complex number.
-The complex number as a string.
Get the real part of the complex number.
-The real part.
Set the real part of the complex number.
-The real part.
Returns the current instance for method chaining.
Get the imaginary part of the complex number.
-The imaginary part.
Set the imaginary part of the complex number.
-The imaginary part.
Returns the current instance for method chaining.
Class MatrixCalculationException
-A custom exception class used specifically for errors related to matrix operations. -This can be thrown during invalid operations such as dimension mismatches, -division by zero, or unsupported matrix formats.
-Extends the base Exception class and provides access to a previous exception for detailed debugging.
-Previous exception
-Get the previous exception.
-The previous exception
Class Area
-Represents a geometric area defined by various shapes such as -rectangles, triangles, polygons, and circles. This class encapsulates -properties related to the shape, its coordinates, and any associated -attributes or hyperlinks. It also provides methods to calculate -coordinates based on the shape type, apply zoom factors, and generate -an HTML representation for use in maps or similar applications.
+Entity Language Class
+This class manages entity language configurations, including loading +labels and handling different language options.
Shape type of the area.
+Current language code.
Coordinates defining the shape.
+Array of PicoLanguage objects.
Hyperlink reference associated with the area.
+Table identity object.
Labels for the entity.
+Additional attributes for the area.
+Entity class name.
Zoom factor for the area.
+Entity language code.
Constructor for the Area class.
+Constructor
One of Rectangle, Triangle, Polygon, or Circle
Zoom factor (default: 1)
Hyperlink reference (optional)
Additional attributes (optional)
The entity to load.
Get coordinates from a rectangle.
+Load data into the object from the given entity.
Rectangle object
The entity to load.
Coordinates of the rectangle
Returns the current instance for method chaining.
Get coordinates from a triangle.
+Add a language to the entity.
Triangle object
Language code.
Reference data for the language.
Flag to indicate whether to use this language immediately.
Coordinates of the triangle
Returns the current instance for method chaining.
Get coordinates from a polygon.
-Polygon object
Coordinates of the polygon
Get coordinates from a circle.
-Circle object
Coordinates of the circle
Get coordinates with optional zoom factor.
-Zoom factor (default: 1)
Adjusted coordinates
Generate HTML representation of the area.
-HTML string for the area
Convert the area object to a string.
-HTML representation of the area
Get the current zoom factor.
-Zoom factor
Set the zoom factor.
-Zoom factor
Returns the current instance for method chaining.
Class Circle
-Represents a circle defined by a center point and a radius. -This class provides methods to calculate the circle's circumference -and area, based on its radius. The circle is defined by its center -coordinates (x, y) and its radius (r).
-Center point of the circle.
-x coordinate of the circle's center.
-y coordinate of the circle's center.
-Radius of the circle.
-Constructor to initialize the Circle with x, y, and r.
-x coordinate of the center
y coordinate of the center
Radius of the circle
Get the circumference of the circle.
-Circumference of the circle
Get the area of the circle.
-Area of the circle
Class LatBounds
-Represents a latitude bounding box defined by southwestern and northeastern latitude values. -This class provides functionality to manage and calculate properties of latitude bounds, -including checking for containment, intersections, and equality with other latitude bounds.
-LatBounds constructor.
-The southwestern latitude.
The northeastern latitude.
Get the southwestern latitude.
-The southwestern latitude.
Get the northeastern latitude.
-The northeastern latitude.
Calculate the midpoint latitude between the southwestern and northeastern latitudes.
-The midpoint latitude.
Check if the latitude bounds are empty (i.e., invalid).
-true if the bounds are empty, false otherwise.
Determine if this LatBounds intersects with another LatBounds.
-The other LatBounds to check for intersection.
true if there is an intersection, false otherwise.
Check if this LatBounds is equal to another LatBounds within a certain margin of error.
-The other LatBounds to compare.
true if they are equal, false otherwise.
Check if a given latitude is contained within the bounds.
-The latitude to check.
true if the latitude is contained, false otherwise.
Extend the bounds to include a new latitude.
-If the bounds are empty, the latitude becomes both the southwestern and northeastern bounds. -If the latitude is less than the southwestern bound, it updates the southwestern bound. -If the latitude is greater than the northeastern bound, it updates the northeastern bound.
-The latitude to extend the bounds with.
Class LatLng
-Represents a geographical point defined by latitude and longitude values. -This class provides methods to manage and manipulate geographic coordinates, -including equality checks and string representations.
-LatLng constructor.
-The latitude value.
The longitude value.
Whether to wrap the longitude value.
If the latitude or longitude is not a valid float.
Get the latitude value.
-The latitude.
Get the longitude value.
-The longitude.
Check if this LatLng is equal to another LatLng object within a certain margin of error.
-The LatLng object to compare.
true if they are equal, false otherwise.
Convert the LatLng object to a string representation.
-The string representation of the LatLng in the format "(lat, lng)".
Convert the LatLng object to a URL-friendly string value.
-The number of decimal places to round to (default: 6).
The latitude and longitude values as a string.
Class LatLngBounds
-Represents a bounding box defined by southwest and northeast LatLng objects.
-LatLngBounds constructor.
-The southwestern LatLng object.
The northeastern LatLng object.
If the provided LatLng objects are invalid.
Get the latitude bounds.
-The latitude bounds of the bounding box.
Get the longitude bounds.
-The longitude bounds of the bounding box.
Get the center point of the bounding box.
-The center point as a LatLng object.
Check if the bounding box is empty.
-true if the bounding box is empty, false otherwise.
Get the southwestern corner of the bounding box.
-The southwestern corner as a LatLng object.
Get the northeastern corner of the bounding box.
-The northeastern corner as a LatLng object.
Get the span of the bounding box as a LatLng object.
-The span defined by the latitude and longitude differences.
Convert the bounding box to a string representation.
-The string representation of the bounding box.
Convert the bounding box to a URL-friendly string value.
-The number of decimal places to round to.
The southwest and northeast corner values as a string.
Check if this LatLngBounds is equal to another LatLngBounds object.
-The LatLngBounds object to compare.
true if they are equal, false otherwise.
Check if this LatLngBounds intersects with another LatLngBounds.
-The LatLngBounds to check for intersection.
true if they intersect, false otherwise.
Extend this bounding box to include another LatLngBounds.
-The LatLngBounds to extend with.
The current instance for method chaining.
Check if this LatLngBounds contains a specific LatLng point.
-The LatLng point to check for containment.
true if the point is contained, false otherwise.
Extend the bounding box to include a new LatLng point.
-The LatLng point to extend with.
The current instance for method chaining.
Class representing a Line with two Point objects.
-This class defines a Line in a 2D space represented by two endpoints, Point A and Point B. -It provides methods to calculate the length of the line and ensure the endpoints are valid Point instances.
-Point A.
-Point B.
-Constructor to initialize the Line with two Point objects.
-Point A.
Point B.
If the parameters are not instances of Point.
Method to calculate the length of the line.
-This method calculates the Euclidean distance between Point A and Point B.
-The length of the line between Point A and Point B.
Class LngBounds
-Represents a longitudinal bounding range defined by southwest and northeast longitude values.
-LngBounds constructor.
-The southwestern longitude value.
The northeastern longitude value.
Get the southwestern longitude.
-The southwestern longitude value.
Get the northeastern longitude.
-The northeastern longitude value.
Get the midpoint of the longitude bounds.
-The midpoint longitude value.
Check if the bounds are empty.
-true if the bounds are empty, false otherwise.
Check if this LngBounds intersects with another LngBounds.
-The LngBounds to check for intersection.
true if they intersect, false otherwise.
Check if this LngBounds is equal to another LngBounds.
-The LngBounds object to compare.
true if they are equal, false otherwise.
Check if a given longitude is contained within the bounds.
-The longitude to check.
true if the longitude is contained, false otherwise.
Extend the bounds to include a new longitude.
-The longitude to extend the bounds with.
Class representing a Map containing multiple Areas.
-This class manages a collection of Area objects, allowing for the addition and retrieval of areas. -It can be initialized with an optional array of Area objects.
-Areas in the map.
-Constructor to initialize the Map with optional areas.
-An array of Area objects to initialize the map with.
Add an area to the map.
-This method appends a new Area object to the map's collection of areas.
-Area to add
Returns the current instance for method chaining.
Get all areas in the map.
-This method returns an array of Area objects contained in the map.
-An array of Area objects
Class representing node attributes.
-This class stores a collection of attribute values associated with a node. -It provides methods for initialization and converting the attributes to a string representation, -suitable for use in contexts such as HTML attributes.
-Values of the node attributes.
-Constructor to initialize the NodeAttribute with values.
-An array of attribute values.
Convert the node attributes to a string representation.
-This method returns the attributes in a format suitable for inclusion in HTML tags, -where each attribute is represented as key="value".
-A string representation of the node attributes.
Class representing a Point with x and y coordinates.
-This class defines a Point in a 2D Cartesian coordinate system, -allowing for the representation of its position and the calculation of distances to other Points.
-X coordinate.
-Y coordinate.
-Constructor to initialize the Point with x and y coordinates.
-X coordinate.
Y coordinate.
Calculate the distance between this Point and another Point.
-This method computes the Euclidean distance between the current Point -and another Point provided as an argument.
-Another Point.
The distance between the two Points.
If the argument is not of type Point.
Calculate the distance between this Point and another Point.
-This method serves as an alias to distanceFrom for better readability.
-Another Point.
The distance between the two Points.
Class representing a polygon defined by a series of points.
-This class allows for the creation and manipulation of polygons, including -adding points, clearing the polygon, and calculating its area and circumference.
-Points that make up the polygon.
-Constructor to initialize the Polygon with an array of Points.
-Initial points for the polygon.
Add a point to the polygon.
-Point to add.
Returns the current instance for method chaining.
Clear all points from the polygon.
-This method removes all points currently defined for the polygon.
-Returns the current instance for method chaining.
Calculate the area of the polygon using the Shoelace formula.
-The area of the polygon.
If the polygon has fewer than 3 points.
Calculate the circumference of the polygon.
-This method computes the total length of the polygon's edges.
-The circumference of the polygon.
If the polygon has fewer than 2 points.
Get the points of the polygon.
-An array of Point objects that define the polygon.
Class representing a rectangle defined by two Point objects.
-This class represents a rectangle using its bottom-left and top-right corner points. -It provides methods to calculate the area and circumference (perimeter) of the rectangle -by utilizing a Polygon representation of the rectangle's corners.
-Bottom-left corner point of the rectangle.
-Top-right corner point of the rectangle.
-Polygon representation of the rectangle.
-Constructor to initialize the Rectangle with two Point objects.
-Bottom-left corner point.
Top-right corner point.
Calculate the area of the rectangle.
-The area of the rectangle.
If the polygon is invalid.
Get the circumference (perimeter) of the rectangle.
-The circumference of the rectangle.
If the polygon is invalid.
Static class SphericalGeometry
-Provides utility functions for computing geodesic angles, distances, areas, and other spherical geometry calculations.
-Get the Earth's radius.
-The Earth's radius in meters.
Computes a bounding rectangle (LatLngBounds instance) from a point and a given radius.
-Reference: http://www.movable-type.co.uk/scripts/latlong-db.html
-The center point as a LatLng object.
The radius in meters.
The computed bounding rectangle.
Computes the heading from one LatLng to another.
-The starting LatLng.
The destination LatLng.
The heading in degrees from the starting point to the destination.
Computes a new LatLng based on a starting point, distance, and heading.
-The starting LatLng.
The distance to move, in meters.
The direction to move, in degrees.
The new LatLng after the offset.
Determines whether a point is contained within a polygon.
-A point object with x() and y() methods for longitude and latitude.
A polygon object with an exteriorRing() method.
true if the point is inside the polygon, false otherwise.
Interpolates between two LatLng points based on a fraction.
-The starting LatLng.
The ending LatLng.
A fraction between 0 and 1.
The interpolated LatLng.
Computes the distance between two LatLng points.
-The first LatLng point.
The second LatLng point.
The distance in yards.
Computes the total length of a series of LatLng points.
-An array of LatLng points.
The total length in yards.
Computes the area of a polygon defined by a series of LatLng points.
-An array of LatLng points defining the polygon.
The area in square meters.
Computes the signed area of a polygon defined by a series of LatLng points.
-An array of LatLng points defining the polygon.
Whether to return a signed area.
The signed area in square meters.
Clamps a latitude value to be within valid bounds.
-The latitude to clamp.
The clamped latitude value.
Wraps a longitude value to be within valid bounds.
-The longitude to wrap.
The wrapped longitude value.
Computes the great circle distance (in radians) between two points. -Uses the Haversine formula.
-The first LatLng point.
The second LatLng point.
The distance in radians.
Computes the spherical excess using L'Huilier's Theorem.
-The first vertex of the triangle.
The second vertex of the triangle.
The third vertex of the triangle.
Whether to return a signed value.
The spherical excess.
Class representing a triangle defined by three Point objects.
-This class represents a triangle in a 2D space using three vertices. -It provides methods to calculate the lengths of the sides and the area using Heron's formula.
-Vertex A of the triangle.
-Vertex B of the triangle.
-Vertex C of the triangle.
-Length of side opposite to vertex A.
-Length of side opposite to vertex B.
-Length of side opposite to vertex C.
-Constructor to initialize the Triangle with three Point objects.
-The first vertex of the triangle.
The second vertex of the triangle.
The third vertex of the triangle.
Calculate the area of the triangle using Heron's formula.
-The area of the triangle.
Entity Language Class
-This class manages entity language configurations, including loading -labels and handling different language options.
-Current language code.
-Array of PicoLanguage objects.
-Table identity object.
-Labels for the entity.
-Entity class name.
-Entity language code.
-Constructor
-The entity to load.
Load data into the object from the given entity.
-The entity to load.
Returns the current instance for method chaining.
Add a language to the entity.
-Language code.
Reference data for the language.
Flag to indicate whether to use this language immediately.
Returns the current instance for method chaining.
Remove a language from the entity.
+Remove a language from the entity.
Language code to remove.
Class Matrix
-Provides basic operations for 2D matrices with real number elements, -including addition, subtraction, multiplication, and element-wise division.
-All matrices must be well-formed (i.e., rectangular and of compatible sizes for the operation).
-Adds two matrices element-wise.
-First matrix.
Second matrix.
Resulting matrix after addition.
If matrix dimensions do not match.
Subtracts matrix B from matrix A element-wise.
-First matrix.
Second matrix.
Resulting matrix after subtraction.
If matrix dimensions do not match.
Multiplies two matrices using standard matrix multiplication.
-First matrix.
Second matrix.
Resulting matrix after multiplication.
If matrix dimensions are not compatible for multiplication.
Divides matrix A by matrix B element-wise.
-First matrix.
Second matrix.
Resulting matrix after element-wise division.
If dimensions do not match or division by zero occurs.
Validates that two matrices have the same dimensions.
-First matrix.
Second matrix.
If dimensions do not match.
(Re)starts the session.
+(Re)starts the session and update cookie.
This method starts a session if it hasn't been started already.
Refreshes the session cookie to extend its lifetime.
+Call this to implement sliding expiration (extend session expiry each request).
+