Download the PHP package bradietilley/carbon-zodiac without Composer
On this page you can find all versions of the php package bradietilley/carbon-zodiac. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package carbon-zodiac
Carbon Zodiac
A simple package that provides an interface for converting dates to Zodiac signs and elements.
Installation
Limitations
Currently, only dates between 1648 and 2644 are supported. If you'd like to utilise this package for dates beyond that range, please make a pull request which includes your requested updates to the NewYears::THRESHOLDS
constant and please cite your source(s).
Usage
You may either use the Carbon
macros, use the BradieTilley\Zodiac\Zodiac
class, or use each class/enum directly. Here are a few examples:
Using Carbon Macros:
Laravel will auto boot the Carbon macros, but should you need to boot it yourself
on non-Laravel projects that use Carbon\Carbon
, it's really easy:
Once booted, or in Laravel apps, you can leverage the Carbon
macros to fetch the data you need:
Using Zodiac Helper:
Alternatively you may wish to not leverage the Carbon
macros at all, which can be achieved via the Zodiac
helper:
For now, only Carbon instances are supported. Future releases might scale this back to be any DateTimeInterface
.
Using Classes Directly:
Extended Usage
Given a zodiac Sign
enum instance, you can then find more details of the sign by leveraging a few helper methods:
The Year
class
The Year
class is a DTO wrapping the integer year (e.g. 2024
) and includes
helper methods to traverse through the years, fetch the associated Sign
and Element
,
and determine the start / end date of the year.
Example usage:
The Sign
enum
The Sign
enum is a PHP Enum object that contains the 12 signs, and can be resolved
via the from*
methods, amongst other approaches documented elsewhere.
Example usage:
The Element
enum
The Element
enum is a PHP Enum object that contains the 5 elements, and can be resolved
via the from*
methods, amongst other approaches documented elsewhere.
Example usage:
Other Usage
There's probably more features or ways to interact with these objects so feel free to have a browse into the code see what's possible.
Issues and Notice:
There's no guarantee anything here is perfect, but it's so far gotten every date correct I have tried. If you spot any issues please open an issue in GitHub.
Author
Source
Lunar New Year thresholds:
In the NewYears
class I've noted the source. Huge thanks to them, and their source.
Element and Sign cycles:
Sourced from various online places to ensure the cycling of signs and elements are correct. No source cited for this, currently.
Element extra information
This refers to an Element's season, direction, fixed element, trine, etc. This data was sourced from... Wikipedia. Take it with a grain of salt, but from what I can tell, it's "correct" 🤷
License
MIT... or whatever is the "use it and have fun without needing to worry about anything" license is.
If you use it and are happy to share your project name/URL, feel free to mention it in a PR and add it below or something.
Where it's used;
- Nowhere yet. lol.