Plugin Directory

Changeset 3297704


Ignore:
Timestamp:
05/21/2025 01:17:01 AM (10 months ago)
Author:
bordoni
Message:

Applying modifications to 0.8.0 (copied from 0.7.2)

Location:
fakerpress/tags/0.8.0
Files:
7 added
17 deleted
25 edited

Legend:

Unmodified
Added
Removed
  • fakerpress/tags/0.8.0/fakerpress.php

    r3296016 r3297704  
    44 * Plugin URI:        https://fakerpress.com
    55 * Description:       FakerPress is a clean way to generate fake data to your WordPress installation, great for developers who need testing
    6  * Version:           0.7.2
     6 * Version:           0.8.0
    77 * Author:            Gustavo Bordoni
    88 * Author URI:        https://bordoni.me
     
    1818
    1919/**
    20  * Version compares to PHP 7.4, so we can use namespaces, anonymous functions
    21  * and a lot of packages require 7.4, so...
     20 * Version compares to PHP 8.0, so we can use namespaces, anonymous functions
     21 * and a lot of packages require 8.0, so...
    2222 */
    23 if ( PHP_VERSION_ID < 70400 ) {
     23if ( PHP_VERSION_ID < 80100 ) {
    2424    if ( ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) && is_admin() ) {
    2525        require_once ABSPATH . 'wp-admin/includes/plugin.php';
    2626
    2727        if ( ! is_plugin_active( plugin_basename( __FP_FILE__ ) ) ) {
    28             wp_print_styles( 'open-sans' );
    29             echo "<style>body{margin: 0 2px;font-family: 'Open Sans',sans-serif;font-size: 13px;line-height: 1.5em;}</style>";
    30             echo '<b>FakerPress</b> requires PHP 7.4 or higher, and the plugin has now disabled itself.' .
    31                 '<br />' .
    32                 'To allow better control over dates, advanced security improvements and performance gain.' .
    33                 '<br />' .
    34                 'Contact your Hosting or your system administrator and ask for this Upgrade to version 7.4 of PHP.';
    35             exit;
     28            // Register activation hook to handle PHP version incompatibility.
     29            return register_activation_hook( __FP_FILE__, '_fp_handle_activation' );
    3630        }
    3731
    38         deactivate_plugins( __FP_FILE__ );
     32        _fp_handle_activation();
    3933    }
    4034} else {
     
    4337    add_action( 'plugins_loaded', 'fakerpress_load_plugin', 50 );
    4438}
     39
     40// Check for PHP version error flag and display notice.
     41add_action( 'admin_notices', '_fp_display_activation_notice' );
     42
     43/**
     44 * Handles plugin activation and version incompatibility.
     45 *
     46 * @since 0.8.0
     47 *
     48 * @return void
     49 */
     50function _fp_handle_activation() {
     51    // Deactivate the plugin immediately upon activation.
     52    deactivate_plugins( plugin_basename( __FP_FILE__ ) );
     53
     54    // Get the plugin data to access version.
     55    $plugin_data = get_plugin_data( __FP_FILE__, false, false );
     56    $version     = ! empty( $plugin_data['Version'] ) ? $plugin_data['Version'] : 'generic';
     57   
     58    // Set a version-specific option with the error type.
     59    update_option( "_fp_activation_error_{$version}", 'php_invalid' );
     60}
     61
     62/**
     63 * Displays PHP version notice if needed.
     64 *
     65 * @since 0.8.0
     66 *
     67 * @return void
     68 */
     69function _fp_display_activation_notice() {
     70    if ( ! is_admin() ) {
     71        return;
     72    }
     73   
     74    if ( ! current_user_can( 'activate_plugins' ) ) {
     75        return;
     76    }
     77   
     78    // Get the plugin data to access version.
     79    $plugin_data = get_plugin_data( __FP_FILE__, false, false );
     80    $version     = ! empty( $plugin_data['Version'] ) ? $plugin_data['Version'] : 'generic';
     81   
     82    // Check for any version-specific error.
     83    $option_name = "_fp_activation_error_{$version}";
     84    $error_type  = get_option( $option_name );
     85   
     86    if ( ! $error_type ) {
     87        return;
     88    }
     89
     90    if ( 'php_invalid' !== $error_type ) {
     91        return;
     92    }
     93    ?>
     94    <div class="error">
     95        <p>
     96            <?php
     97            printf(
     98                /* translators: %s: Plugin name */
     99                esc_html__( '%s requires PHP 8.1 or higher, and the plugin has now disabled itself.', 'fakerpress' ),
     100                '<b>FakerPress</b>'
     101            );
     102            ?>
     103            <br />
     104            <?php esc_html_e( 'To allow better control over dates, advanced security improvements and performance gain.', 'fakerpress' ); ?>
     105            <br />
     106            <?php esc_html_e( 'Contact your Hosting or your system administrator and ask for this Upgrade to version 8.1 of PHP.', 'fakerpress' ); ?>
     107        </p>
     108    </div>
     109    <?php
     110
     111    // Clear the flag after displaying the notice, only delete the flag if the notice was displayed.
     112    delete_option( $option_name );
     113}
  • fakerpress/tags/0.8.0/readme.txt

    r3296016 r3297704  
    44Requires at least: 5.5
    55Tested up to:      6.8.1
    6 Requires PHP:      7.4
    7 Stable tag:        0.7.2
     6Requires PHP:      8.1
     7Stable tag:        0.8.0
    88License:           GPLv2 or later
    99License URI:       http://www.gnu.org/licenses/gpl-2.0.html
     
    100100== Changelog ==
    101101
     102= 0.8.0 &mdash; 20 of May 2025 =
     103
     104* Version - Update dependency `cakephp/chronos` to `3.1.0`
     105* Version - Update PHP min version to `8.1+`
     106* Fix - Resolve PHP `8.4+` problems specially arounnd incompatibility with Chronos and notices.
     107
    102108= 0.7.2 &mdash; 18 of May 2025 =
    103109
  • fakerpress/tags/0.8.0/src/FakerPress/Plugin.php

    r3296016 r3297704  
    11<?php
     2/**
     3 * Plugin main class.
     4 *
     5 * @since 0.1.0
     6 *
     7 * @package FakerPress
     8 * @subpackage Main
     9 * @copyright Copyright (c) 2014-2025, Gustavo Bordoni
     10 * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+
     11 */
    212
    313namespace FakerPress;
    414
     15/**
     16 * Main plugin class used to setup all the necessary components.
     17 *
     18 * @since 0.1.0
     19 */
    520class Plugin {
    621    /**
     
    1126     * @var string
    1227     */
    13     public const VERSION = '0.7.2';
     28    public const VERSION = '0.8.0';
    1429
    1530    /**
  • fakerpress/tags/0.8.0/src/data/readme.php

    r3296016 r3297704  
    1 <?php return json_decode( '{"headers":{"name":"headers","content":"=== FakerPress ===\nContributors:      bordoni\nTags:              generator, dummy content, lorem ipsun, testing, developer\nRequires at least: 5.5\nTested up to:      6.8.1\nRequires PHP:      7.4\nStable tag:        0.7.1\nLicense:           GPLv2 or later\nLicense URI:       http:\/\/www.gnu.org\/licenses\/gpl-2.0.html\nDonate link:       https:\/\/fakerpress.com\/r\/sponsor\n\nFakerPress is a clean way to generate fake and dummy content to your WordPress, great for developers who need testing\n\n"},"description":{"name":"Description","content":"\n\nWhenever you create a new Theme or Plugin you will always need to create custom data to test whether your plugin is working or not, and as Developers ourselves we had this problem quite alot.\n\nOur goal with this plugin is to fill this gap where you have problem with a good solution both for Developers and for Users of WordPress.\n\n\u003E **Note: This plugin requires PHP 7.4 or higher to be activated.**\n\n[**Checkout our GitHub Repository**](http:\/\/fakerpress.com\/r\/github)\n\n---\n\n= Components Included =\n\n* Posts\n* Custom Post Types\n* Meta Data\n* Featured Image\n* Users\n* Tags\n* Categories\n* Comments\n* Custom Comment Types\n\n= Creating Dummy Content =\nNormally a WordPress developer will need to perform the task of filling up an empty theme with dummy content, and doing this manually can be really time consuming, the main reasons this plugin was create was to speed up this process.\n\n= Random Featured Images =\nCreate randomly generated attachments as the Featured Images for your WordPress dummy content.\n\n= Create random Meta Information =\nWordPress has Meta for Users, Posts, Terms and Comments, FakerPress will allow you to generate custom dummy meta for all four, with *20 types of Data*\n\n= Delete the Content Generated =\nAfter you are done with your testing it should be easy to delete all the content created using FakerPress, now you will be able to do it.\n\n= Generate Random HTML =\nWhen creating dummy posts what you really want is that the HTML is really random so that you might see bugs that an XML import wouldn\u0027t.\n\n= Generate Images in your HTML =\nWhen you are testing your website images are important, so FakerPress will allow you to output Images to your HTML tests.\n\n= Real Browser data on User Comments =\nFor comments our plugin is prepared to generate a real Browser data instead of leaving the field empty.\n\n= Random Terms generation =\nFor creating and assigning the terms you will have a much better tool that will allow you to select which kind of taxonomy you want to assign to your posts, and leaving the randomization to the plugin\u0027s code.\n\n= Real random User profiles =\nIf you fill up your WordPress with any data for the user profiles you might not catch an edge case, this plugin will fill up the fields with data that will really matter in the tests.\n\n= Types of Meta Included =\n* Attachment\n* WP_Query\n* Number\n* Elements\n* Letter\n* Words\n* Text\n* HTML\n* Lexify\n* Asciify\n* Regexify\n* Person\n* Geo Information\n* Company\n* Date\n* TimeZone\n* Email\n* Domain\n* IP\n* Browser User Agent\n\n= Languages =\nWe moved away from _Transifex_ due to the new GlotPress on WordPress.org, so if you want to translate FakerPress to your language please [follow this guidelines](https:\/\/make.wordpress.org\/polyglots\/handbook\/rosetta\/theme-plugin-directories\/#translating-themes-plugins).\n\n= See room for improvement? =\n\nGreat! There are several ways you can get involved to help make FakerPress better:\n\n1. **Report Bugs:** If you find a bug, error or other problem, please report it! You can do this by [creating a new topic](http:\/\/wordpress.org\/support\/plugin\/fakerpress) in the plugin forum. Once a developer can verify the bug by reproducing it, they will create an official bug report in GitHub where the bug will be worked on.\n2. **Suggest New Features:** Have an awesome idea? Please share it! Simply [create a new topic](http:\/\/wordpress.org\/support\/plugin\/fakerpress) in the plugin forum to express your thoughts on why the feature should be included and get a discussion going around your idea.\n3. **Issue Pull Requests:** If you\u0027re a developer, the easiest way to get involved is to help out on [issues already reported](https:\/\/github.com\/bordoni\/fakerpress\/issues) in GitHub. Be sure to check out the [contributing guide](https:\/\/github.com\/bordoni\/fakerpress\/blob\/master\/contributing.md) for developers.\n\nThank you for wanting to make FakerPress better for everyone! [We salute you](https:\/\/www.youtube.com\/watch?v=8fPf6L0XNvM).\n\n"},"changelog":{"name":"Changelog","content":"\n\n= 0.7.1 \u0026mdash; 18 of May 2025 =\n\n* Fix - Move the registration of the menus to avoid problems with `_load_textdomain_just_in_time()` notices\n* Fix - Resolve problems with `count()` applying to a String instead of an Array for PHP 8.1+\n* Fix - Resolve fatals for newChronos being a bad string replacement.\n\n= 0.7.0 \u0026mdash; 16 of May 2025 =\n\n* Version - Update dependency `fakerphp\/faker` to `1.24`\n* Version - Update dependency `lucatume\/di52` to `0.4`\n* Tweak - Modified date handling from using `Carbon` to use `Chronos`.\n* Fix - Improved password for the randomized Users created, prevents weird scenarios with faked users allowing brute-force login. Props @rinatkhaziev\n* Fix - Prevent fatals related to `$min` param on Meta Value generation for PHP 8.1+. Props @kubiq\n\n= 0.6.6 \u0026mdash; 26 of April 2024 =\n\n* Fix - Prevent notices related to deprecated usage of Faker methods that were being called as properties.\n* Fix - Prevent fatals related to bad typecasting of Faker methods used for meta generation. props @helgatheviking\n\n= 0.6.5 \u0026mdash; 26 of April 2024 =\n\n* Fix - Ensure meta generation for Users, Terms and Comments work since changes made on version `0.6.2`. props @helgatheviking\n\n= 0.6.4 \u0026mdash; 21 of April 2024 =\n\n* Fix - Ensure that Faker is also included via Strauss, to prevent conflicts with other plugins.\n* Fix - Resolve Fatal where trying to create posts, comments or terms would fail because of missing classes.\n\n= 0.6.3 \u0026mdash; 21 of April 2024 =\n\n* Fix - Prevent fatal errors because of malformed composer autoload files.\n\n= 0.6.2 \u0026mdash; 21 of April 2024 =\n\n* Version - Updated composer dependency `fakerphp\/faker` to version `1.23`.\n* Feature - Include consistent user generation, to avoid users feeling a disjointed. props @helgatheviking\n* Tweak - Include the ability to regenerate module data, allowing us to fetch values from earlier generations.\n* Tweak - Include properly use Composer for autoloading and dependencies without conflicting with other plugins.\n* Tweak - Include `lucatume\/di52` and `nesbot\/carbon` Strauss dependencies, which prevents conflicts with other plugins.\n* Fix - Switch from using Placeholder.com to Placehold.co, as the first one was not working properly anymore. props @cgarofalo\n* Fix - Searching terms nonce had a typo, preventing terms search from working as expected. props @cyrusdavid\n* Fix - Prevent namespace problems with nonexistent classes, specially around Exceptions.\n* Fix - Resolve a problem with Numbers Meta throwing errors on PHP 8.0+ [#168]\n\n= 0.6.1 \u0026mdash; 04 of April 2023 =\n\n* Requirement - PHP Version 7.4 required for usage of FakerPress, important step to allow further improvements and tests.\n* Version - Updated composer dependency `lucatume\/di52` to version `3.3.1`.\n* Version - Updated composer dependency `fakerphp\/faker` to version `1.21`.\n* Version - Updated composer dependency `nesbot\/carbon` to version `2.66`.\n* Fix - Resolve some errors happening with Carbon and version 8.2 of PHP.\n\n= 0.6.0 \u0026mdash; 30 of March 2022 =\n\n* Requirement - PHP Version 7.1 required for usage of FakerPress, important step to allow further improvements and tests.\n* Feature - Modifications to the internal Modules of FakerPress to enable future work around WP-CLI.\n* Feature - Include a new way to handle Administration Pages, included here to enable future work.\n* Enhancement - Modifications to Select2 Styles for better accessibility usage.\n* Tweak - Faker version dependency updated from `fzaninotto\/Faker` to `fakerphp\/Faker\/`.\n* Tweak - Move everything into the FakerPress namespace.\n* Tweak - Autoload using Composer properly.\n\n= 0.5.3 \u0026mdash; 04 of March 2022 =\n\n* Fix - Ensure Select2 usage of AJAX search properly encodes on all usages props @TheMMMdev\n* Fix - Ensure Select2 usage of AJAX properly checks for nonces and permissions props @TheMMMdev\n\n= 0.5.2 \u0026mdash; 27 of January 2022 =\n\n* Feature: Proper changelog page for users trying to figure out what has changed in the latest version of FakerPress.\n* Feature: Excerpt size field added to ensure better control over Post generation prop @gtsantos\n* Tweak: jQuery 3.5.X compatibility\n* Fix: Prevent warning around post_excerpt usage introduced earlier on in the year. props @pattisahusiwa\n* Fix: One more PHP 8 compatibility problem related to the generation of passwords props @DumahX\n* Fix: Prevent PHP 8 from throwing a warning because of unnecessary `unlink()` call for attachments props @wpuzman\n* Fix: Resolve problems around failed inline images that were unavailable which would cause a PHP Warning.\n\n= 0.5.1 \u0026mdash; 05 of January 2021 =\n\n* Feature: Completely change folder structure to comply with [PSR-4](https:\/\/www.php-fig.org\/psr\/psr-4\/) autoloading with namespaces.\n* Feature: Included a Fields API to more easily generate Fields for controlling fields used in the admin pages.\n* Feature: Included a Template class to allow better separation of HTML and PHP files.\n* Tweak: Include compatibility with PHP 8+\n* Tweak: More well structured `composer.json` and using it\u0027s autoloader.\n* Tweak: All PHP files now live inside of `src` folder.\n* Tweak: Moved all files to use the `[]` array syntax.\n* Tweak: GitHub repository no longer tracks the `vendor` folder.\n* Fix: Correctly order the `fp_array_get` params with it\u0027s usage props @henrikwirth.\n* Fix: Make sure WordPress 5.6+ administration proper display fields.\n* Fix: Menu icon is properly displayed on version of WordPress 5.5 or higher\n\n= 0.5.0 \u0026mdash; 09 of November, 2019 =\n\n* Feature: Removed 500px as a image provider as that source was deprecated a while ago.\n* Fix: Properly handle downloading of images into WordPress, which makes this a lot safer and faster.\n* Fix: Resolved the problem where images from the Meta Attachment were been generated with 0x0 size and breaking the attachment.\n* Fix: Removed 500px as a image provider as that source was deprecated a while ago.\n* Fix: Moved from Unplash.it to their new name as Lorem Picsum.\n* Tweak: Started adding proper docblocks to the new methods. Note it will take a couple versions to have all methods with proper docblocks.\n* Tweak: Control timeout of image download with filter `fakerpress.module.attachment.download_url_timeout` defaulting to 10 seconds per attachment.\n* Tweak: Update required version of PHP to 5.6 to be more along the requirements of WordPress.\n* Tweak: Test and update the version of WordPress FakerPress was tested up to, now on 5.3.\n* Tweak: Updated the version of fzaninotto\/faker (v1.6.0 =\u003E v1.8.0)\n* Tweak: Updated the version of nesbot\/carbon (1.21.0 =\u003E 1.39.1)\n\n= 0.4.11 \u0026mdash; 25 of February, 2018 =\n\n* Fix: Prevent fatals from oversight with Namespace and Classnames for User and Post generation \u0026mdash; Thanks [@radgh](https:\/\/wordpress.org\/support\/topic\/fakerpress-generate-users-fails\/) \u0026 [@johny-dotpad](https:\/\/wordpress.org\/support\/topic\/post-generation-fails\/)\n* Fix: Rollback change to `file_get_contents` it was making peoples servers hang to long \u0026mdash; Thanks [@bilimokur](https:\/\/wordpress.org\/support\/topic\/most-images-are-corrupted\/)\n\n= 0.4.10 \u0026mdash; 11 of February, 2018 =\n\n* Feature: Added size control to Post Content, Comment Content and User Description\n* Fix: On image and attachment download we try one more time using `file_get_contents` \u0026mdash; Thanks [@lazlo-toth](https:\/\/wordpress.org\/support\/topic\/most-of-the-featured-image-links-appear-to-be-invalid\/)\n* Fix: Resolve Quantity Min and Max fields weird interaction \u0026mdash; Thanks [@rahmantanvir](https:\/\/github.com\/bordoni\/fakerpress\/issues\/124)\n\n= 0.4.9 \u0026mdash; 07 of August, 2017 =\n\n* Feature: Allow Attachments to be generated with a given Width and Height range \u0026mdash; Thanks [@COLABORATI](https:\/\/github.com\/bordoni\/fakerpress\/issues\/86)\n* Feature: Generate `post_excerpt` for Posts (how I forgot that is beyond me) \u0026mdash; Thanks [@njbarrett](https:\/\/github.com\/bordoni\/fakerpress\/issues\/104)\n* Fix: Meta field rules were not respecting Configurations due to a JavaScript bug on indexing the fields \u0026mdash; Thanks [@ckpicker](https:\/\/github.com\/bordoni\/fakerpress\/issues\/115)\n* Fix: Resolve problems where attachments wouldn\u0027t get setup correctly and throw an Empty Message \u0026mdash; Thanks [@r083r7 and @oyvind_skjelstad](https:\/\/wordpress.org\/support\/topic\/featured-image-not-showing-up-6)\n* Fix: Allow Term Meta to generate the fields correctly again \u0026mdash; Thanks [@stratboy](https:\/\/github.com\/bordoni\/fakerpress\/issues\/105)\n* Tweak: Prevent `_encloseme` and `_pingme` for FakerPress generated Posts\n\n= 0.4.8 \u0026mdash; 18 of July, 2017 =\n\n* Feature: Now Comments can be generated with different types, allowing for WooCommerce Notes for example - Thanks [@dibbyo456](https:\/\/wordpress.org\/support\/topic\/can-i-create-custom-comments\/)\n* Feature: Comments for Custom Post Types - Thanks [@jasondevine](https:\/\/github.com\/bordoni\/fakerpress\/issues\/109)\n* Tweak: Added two new filters to Filter Meta Value `fakerpress.module.meta.value` and `fakerpress.module.meta.{$key}.value` - Thanks [@Mte90](https:\/\/github.com\/bordoni\/fakerpress\/pull\/111)\n* Fix: Resolve problems on failed Meta generation - Thanks [@Mte90](https:\/\/github.com\/bordoni\/fakerpress\/pull\/110)\n* Fix: Typo on Provider text for Attachment Meta - Thanks [@codiceovvio](https:\/\/github.com\/bordoni\/fakerpress\/pull\/103)\n\n= 0.4.7 \u0026mdash; 2 of October, 2016 =\n\n* Feature: Image Attachment Meta Field to allow more Flexibility all around the plugin\n\n= 0.4.6 \u0026mdash; 14 of June, 2016 =\n\n* Fix: Post Meta and taxonomy is finally working again \u0026mdash; Thanks [@peachey_a](https:\/\/wordpress.org\/support\/topic\/generated-posts-not-assigned-categories) and [@zoeitsolutions](https:\/\/wordpress.org\/support\/topic\/user-meta-not-being-generated)\n* Fix: Allow Meta Number generation using any type of range, doesn\u0027t limit from 0 to 9\n\n= 0.4.5 \u0026mdash; 11 of June, 2016 =\n\n* Fix: Users Module was using Post Meta methods on flag related methods, preventing the users to be deleted when \u0022Let it Go!\u0022 \u0026mdash; Thanks [@derpixler](https:\/\/github.com\/bordoni\/fakerpress\/issues\/84)\n* Fix: Taxonomy and Meta Modules had a compatibility problem with Faker, preveting users to use Meta and Taxonomy Properly \u0026mdash; Thanks [@rayrutjes](https:\/\/github.com\/bordoni\/fakerpress\/issues\/94)\n* Tweak: Add a better description for a few fields\n* Tweak: Include [latest code from Faker](https:\/\/github.com\/fzaninotto\/Faker) version \u003E 1.6.0\n\n= 0.4.4 \u0026mdash; 1 of April, 2016 =\n\n* Feature: Address Meta templating now allows you to fetch Country ABBR and Code \u0026mdash; Thanks [@kirilisa](https:\/\/wordpress.org\/support\/topic\/excellent-3360)\n* Tweak: Include [latest code from Faker](https:\/\/github.com\/fzaninotto\/Faker) version \u003E 1.5.0\n* Tweak: WP_Query Meta for attachments is a little bit easier now, prediction of forgotten `post_status`\n* Tweak: Make the Post Parent selection easier to know which posts by showing more information on the items \u0026mdash; Thanks [@fxbernard](https:\/\/github.com\/bordoni\/fakerpress\/issues\/81)\n* Fix: Get some missing Text Domains working \u0026mdash; Thanks [@ginsterbusch](https:\/\/github.com\/bordoni\/fakerpress\/issues\/77)\n\n= 0.4.3 \u0026mdash; 1 of March, 2016 =\n\n* Feature: No more Hot-linking external sites on Content Images \u0026mdash; Thanks [b0rg](https:\/\/profiles.wordpress.org\/b0rg) + [mvaneijgen](https:\/\/profiles.wordpress.org\/mvaneijgen) + [okvee](https:\/\/profiles.wordpress.org\/okvee)\n* Tweak: Use `wp_remote_get` to fetch external images \u0026mdash; Thanks [revaxarts](https:\/\/twitter.com\/revaxarts)\n* Tweak: Improve how we handle the Deletes to make sure it doesn\u0027t delete all your site \u0026mdash; Thanks [Paul Mckay](https:\/\/twitter.com\/McKay_1988\/status\/700299519825723392)\n* Fix: Prevent Notices from happening when no Image providers were selected\n\n= 0.4.2 \u0026mdash; 9 of November, 2015 =\n\n* Feature: Include meta for Terms for WordPress 4.4 and Up\n* Tweak: Include a more granular control over Taxonomy selector for Posts\n* Fix: CSS changes for WordPress 4.4\n\n= 0.4.1 \u0026mdash; 24 of September, 2015 =\n\n* Tweak: Improve Modules code in general, if you have custom code based on Modules please check ([#71](https:\/\/github.com\/bordoni\/fakerpress\/pull\/71))\n* Fix: Generate button was locking after a warning for trying a bad request\n* Fix: Improved Modules JavaScript to prevent duplicated arguments on AJAX requests \u0026mdash; Thanks [Jonathan Brinley](https:\/\/profiles.wordpress.org\/jbrinley\/)\n\n= 0.4.0 \u0026mdash; 21 of September, 2015 =\n\n* Feature: Now Modules use AJAX to fake, AKA no more timeouts for big dummy creation\n* Fix: handle WP_Error on term creation, avoids fatal errors if the term already exists \u0026mdash; Thanks [Jonathan Brinley](https:\/\/profiles.wordpress.org\/jbrinley\/)\n\n= 0.3.3 \u0026mdash; 10 of June, 2015 =\n\n* Tweak: Our menus and submenus no longer require JavaScript to work\n* Tweak: Featured Images now are linked to the post using the `post_parent` column \u0026mdash; Reported by [Bruno DC](https:\/\/profiles.wordpress.org\/decarvalho_bruno)\n* Fix: Dates on Meta fields are fully working again \u0026mdash; Thanks [Ethan Clevenger](https:\/\/profiles.wordpress.org\/eclev91)\n\n= 0.3.2 \u0026mdash; 25 of May, 2015 =\n\n* New: Including LoremPixel as a Image Provider \u0026mdash; Thanks [examinedliving](https:\/\/github.com\/examinedliving)\n* Fix: A few JavaScript\/jQuery tweeks for better Select2 Handling on Dates\n* Fix: Intervals now have a better Handling for non-timed Strings \u0026mdash; Thanks [alfiemx_](https:\/\/profiles.wordpress.org\/alfiemx_)\n* Fix: Better verification of Carbon inclusion \u0026mdash; Thanks [Frankie Jarrett](https:\/\/profiles.wordpress.org\/fjarrett\/)\n* Fix: Closures now using self variables better, prevents Fatal Error \u0026mdash; Thanks [fccoelho7](https:\/\/profiles.wordpress.org\/fccoelho7\/)\n\n= 0.3.1 \u0026mdash; 02 of May, 2015 =\n\n* Fix: Date Meta Field is now working as expected\n* Fix: Empty meta fields don\u0027t throw Fatal Errors anymore \u0026mdash; Thanks [Jeffrey Carandang](https:\/\/profiles.wordpress.org\/phpbits\/)\n\n= 0.3.0 \u0026mdash; 01 of May, 2015 =\n\n* New: Now you will be able to generate Custom dummy Meta for your Posts, Users and Comments\n\n= 0.2.2 \u0026mdash; 15 of April, 2015 =\n\n* New: 500px as a Image provider ( You will need a Customer App Key )\n* Tweak: New formula for Taxonomy randomization for Posts ( with new filters )\n\n= 0.2.1 \u0026mdash; 02 of April, 2015 =\n\n* Fix: User generator now working again (sorry about that)\n\n= 0.2.0 \u0026mdash; 01 of April, 2015 =\n\n* New: Featured Images is now an Option on our Plugin\n* New: Handling of Post Meta, still under the hood but preparation for the next versions\n\n= 0.1.6 \u0026mdash; 07 of March, 2015 =\n\n* Fix: Prevent Carbon to Fatal error if trying to be included twice ([#50](https:\/\/github.com\/bordoni\/fakerpress\/issues\/50))\n* Tweak: Better checking for the content flag when deleting\n\n= 0.1.5 \u0026mdash; 03 September, 2014 =\n\n* New: Allow post Parent to be chosen on the Admin Form ([#35](https:\/\/github.com\/bordoni\/fakerpress\/issues\/35))\n* New: Now allow Image to be used in HTML, with Placehold.it ([#38](https:\/\/github.com\/bordoni\/fakerpress\/issues\/38))\n* Tweak: Allow users to choose which HTML tags will be used ([#37](https:\/\/github.com\/bordoni\/fakerpress\/issues\/37))\n* Tweak: User Select2 now uses AJAX to prevent bugs on bigger databases ([#43](https:\/\/github.com\/bordoni\/fakerpress\/issues\/43))\n* Tweak: Now you can select a range of items to be randomized, instead of always having to input a single number ([#44](https:\/\/github.com\/bordoni\/fakerpress\/issues\/44))\n\n= 0.1.4 \u0026mdash; 15 of August, 2014 =\n\n* New: Delete all content created by Fakerpress ([#26](https:\/\/github.com\/bordoni\/fakerpress\/issues\/26))\n* New: Allow users to control `comment_status` on Posts ([#26](https:\/\/github.com\/bordoni\/fakerpress\/issues\/26))\n* New: Predefined interval set of dates ([#21](https:\/\/github.com\/bordoni\/fakerpress\/issues\/21))\n* Tweak: Prevent the user from selecting a bad combination of date fields ([#20](https:\/\/github.com\/bordoni\/fakerpress\/issues\/20))\n\n= 0.1.3 \u0026mdash; 25 of June, 2014 =\n\n* Fixing a problem where the UI folder was not included in the final version\n\n= 0.1.2 \u0026mdash; 24 of June, 2014 =\n\n* New: Admin messages for all pages ([#10](https:\/\/github.com\/bordoni\/fakerpress\/issues\/10))\n* New: Select Date range for Comments and Posts ([#11](https:\/\/github.com\/bordoni\/fakerpress\/issues\/11))\n* New: Select Author sampling group for Posts ([#11](https:\/\/github.com\/bordoni\/fakerpress\/issues\/11))\n* New: Roles sampling group for Users ([#13](https:\/\/github.com\/bordoni\/fakerpress\/issues\/13))\n* New: Taxonomies sampling group for Terms ([#13](https:\/\/github.com\/bordoni\/fakerpress\/issues\/13))\n* New: Selection of Post Type for Posts ([#13](https:\/\/github.com\/bordoni\/fakerpress\/issues\/13))\n* New: Selection of Terms sampling group for Posts ([#13](https:\/\/github.com\/bordoni\/fakerpress\/issues\/13))\n* Tweak: Select2 usage to improve fields ([#13](https:\/\/github.com\/bordoni\/fakerpress\/issues\/13))\n* Fix: `admin_title` been overwritten ([#14](https:\/\/github.com\/bordoni\/fakerpress\/issues\/14))\n\n= 0.1.1 \u0026mdash; 17 of June, 2014 =\n\n* Fatal Error generate by a missing file Carbon related fixed\n\n= 0.1.0 \u0026mdash; 17 of June, 2014 =\n\n* First initial concept of using [Faker](https:\/\/github.com\/fzaninotto\/Faker) to generate data on WordPress","versions":{"0.7.1":{"number":"0.7.1","date":"18 of May 2025","content":"* Fix - Move the registration of the menus to avoid problems with `_load_textdomain_just_in_time()` notices\n* Fix - Resolve problems with `count()` applying to a String instead of an Array for PHP 8.1+\n* Fix - Resolve fatals for newChronos being a bad string replacement.","html":"\u003Cul\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Move the registration of the menus to avoid problems with \u003Ccode\u003E_load_textdomain_just_in_time()\u003C\/code\u003E notices\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Resolve problems with \u003Ccode\u003Ecount()\u003C\/code\u003E applying to a String instead of an Array for PHP 8.1+\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Resolve fatals for newChronos being a bad string replacement.\u003C\/p\u003E\u003C\/li\u003E\n\u003C\/ul\u003E"},"0.7.0":{"number":"0.7.0","date":"16 of May 2025","content":"* Version - Update dependency `fakerphp\/faker` to `1.24`\n* Version - Update dependency `lucatume\/di52` to `0.4`\n* Tweak - Modified date handling from using `Carbon` to use `Chronos`.\n* Fix - Improved password for the randomized Users created, prevents weird scenarios with faked users allowing brute-force login. Props @rinatkhaziev\n* Fix - Prevent fatals related to `$min` param on Meta Value generation for PHP 8.1+. Props @kubiq","html":"\u003Cul\u003E\n\u003Cli\u003E\u003Cp\u003EVersion - Update dependency \u003Ccode\u003Efakerphp\/faker\u003C\/code\u003E to \u003Ccode\u003E1.24\u003C\/code\u003E\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EVersion - Update dependency \u003Ccode\u003Elucatume\/di52\u003C\/code\u003E to \u003Ccode\u003E0.4\u003C\/code\u003E\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003ETweak - Modified date handling from using \u003Ccode\u003ECarbon\u003C\/code\u003E to use \u003Ccode\u003EChronos\u003C\/code\u003E.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Improved password for the randomized Users created, prevents weird scenarios with faked users allowing brute-force login. Props @rinatkhaziev\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Prevent fatals related to \u003Ccode\u003E$min\u003C\/code\u003E param on Meta Value generation for PHP 8.1+. Props @kubiq\u003C\/p\u003E\u003C\/li\u003E\n\u003C\/ul\u003E"},"0.6.6":{"number":"0.6.6","date":"26 of April 2024","content":"* Fix - Prevent notices related to deprecated usage of Faker methods that were being called as properties.\n* Fix - Prevent fatals related to bad typecasting of Faker methods used for meta generation. props @helgatheviking","html":"\u003Cul\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Prevent notices related to deprecated usage of Faker methods that were being called as properties.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Prevent fatals related to bad typecasting of Faker methods used for meta generation. props @helgatheviking\u003C\/p\u003E\u003C\/li\u003E\n\u003C\/ul\u003E"},"0.6.5":{"number":"0.6.5","date":"26 of April 2024","content":"* Fix - Ensure meta generation for Users, Terms and Comments work since changes made on version `0.6.2`. props @helgatheviking","html":"\u003Cul\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Ensure meta generation for Users, Terms and Comments work since changes made on version \u003Ccode\u003E0.6.2\u003C\/code\u003E. props @helgatheviking\u003C\/p\u003E\u003C\/li\u003E\n\u003C\/ul\u003E"},"0.6.4":{"number":"0.6.4","date":"21 of April 2024","content":"* Fix - Ensure that Faker is also included via Strauss, to prevent conflicts with other plugins.\n* Fix - Resolve Fatal where trying to create posts, comments or terms would fail because of missing classes.","html":"\u003Cul\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Ensure that Faker is also included via Strauss, to prevent conflicts with other plugins.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Resolve Fatal where trying to create posts, comments or terms would fail because of missing classes.\u003C\/p\u003E\u003C\/li\u003E\n\u003C\/ul\u003E"},"0.6.3":{"number":"0.6.3","date":"21 of April 2024","content":"* Fix - Prevent fatal errors because of malformed composer autoload files.","html":"\u003Cul\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Prevent fatal errors because of malformed composer autoload files.\u003C\/p\u003E\u003C\/li\u003E\n\u003C\/ul\u003E"},"0.6.2":{"number":"0.6.2","date":"21 of April 2024","content":"* Version - Updated composer dependency `fakerphp\/faker` to version `1.23`.\n* Feature - Include consistent user generation, to avoid users feeling a disjointed. props @helgatheviking\n* Tweak - Include the ability to regenerate module data, allowing us to fetch values from earlier generations.\n* Tweak - Include properly use Composer for autoloading and dependencies without conflicting with other plugins.\n* Tweak - Include `lucatume\/di52` and `nesbot\/carbon` Strauss dependencies, which prevents conflicts with other plugins.\n* Fix - Switch from using Placeholder.com to Placehold.co, as the first one was not working properly anymore. props @cgarofalo\n* Fix - Searching terms nonce had a typo, preventing terms search from working as expected. props @cyrusdavid\n* Fix - Prevent namespace problems with nonexistent classes, specially around Exceptions.\n* Fix - Resolve a problem with Numbers Meta throwing errors on PHP 8.0+ [#168]","html":"\u003Cul\u003E\n\u003Cli\u003E\u003Cp\u003EVersion - Updated composer dependency \u003Ccode\u003Efakerphp\/faker\u003C\/code\u003E to version \u003Ccode\u003E1.23\u003C\/code\u003E.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFeature - Include consistent user generation, to avoid users feeling a disjointed. props @helgatheviking\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003ETweak - Include the ability to regenerate module data, allowing us to fetch values from earlier generations.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003ETweak - Include properly use Composer for autoloading and dependencies without conflicting with other plugins.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003ETweak - Include \u003Ccode\u003Elucatume\/di52\u003C\/code\u003E and \u003Ccode\u003Enesbot\/carbon\u003C\/code\u003E Strauss dependencies, which prevents conflicts with other plugins.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Switch from using Placeholder.com to Placehold.co, as the first one was not working properly anymore. props @cgarofalo\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Searching terms nonce had a typo, preventing terms search from working as expected. props @cyrusdavid\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Prevent namespace problems with nonexistent classes, specially around Exceptions.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Resolve a problem with Numbers Meta throwing errors on PHP 8.0+ [#168]\u003C\/p\u003E\u003C\/li\u003E\n\u003C\/ul\u003E"},"0.6.1":{"number":"0.6.1","date":"04 of April 2023","content":"* Requirement - PHP Version 7.4 required for usage of FakerPress, important step to allow further improvements and tests.\n* Version - Updated composer dependency `lucatume\/di52` to version `3.3.1`.\n* Version - Updated composer dependency `fakerphp\/faker` to version `1.21`.\n* Version - Updated composer dependency `nesbot\/carbon` to version `2.66`.\n* Fix - Resolve some errors happening with Carbon and version 8.2 of PHP.","html":"\u003Cul\u003E\n\u003Cli\u003E\u003Cp\u003ERequirement - PHP Version 7.4 required for usage of FakerPress, important step to allow further improvements and tests.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EVersion - Updated composer dependency \u003Ccode\u003Elucatume\/di52\u003C\/code\u003E to version \u003Ccode\u003E3.3.1\u003C\/code\u003E.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EVersion - Updated composer dependency \u003Ccode\u003Efakerphp\/faker\u003C\/code\u003E to version \u003Ccode\u003E1.21\u003C\/code\u003E.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EVersion - Updated composer dependency \u003Ccode\u003Enesbot\/carbon\u003C\/code\u003E to version \u003Ccode\u003E2.66\u003C\/code\u003E.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Resolve some errors happening with Carbon and version 8.2 of PHP.\u003C\/p\u003E\u003C\/li\u003E\n\u003C\/ul\u003E"},"0.6.0":{"number":"0.6.0","date":"30 of March 2022","content":"* Requirement - PHP Version 7.1 required for usage of FakerPress, important step to allow further improvements and tests.\n* Feature - Modifications to the internal Modules of FakerPress to enable future work around WP-CLI.\n* Feature - Include a new way to handle Administration Pages, included here to enable future work.\n* Enhancement - Modifications to Select2 Styles for better accessibility usage.\n* Tweak - Faker version dependency updated from `fzaninotto\/Faker` to `fakerphp\/Faker\/`.\n* Tweak - Move everything into the FakerPress namespace.\n* Tweak - Autoload using Composer properly.","html":"\u003Cul\u003E\n\u003Cli\u003E\u003Cp\u003ERequirement - PHP Version 7.1 required for usage of FakerPress, important step to allow further improvements and tests.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFeature - Modifications to the internal Modules of FakerPress to enable future work around WP-CLI.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFeature - Include a new way to handle Administration Pages, included here to enable future work.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EEnhancement - Modifications to Select2 Styles for better accessibility usage.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003ETweak - Faker version dependency updated from \u003Ccode\u003Efzaninotto\/Faker\u003C\/code\u003E to \u003Ccode\u003Efakerphp\/Faker\/\u003C\/code\u003E.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003ETweak - Move everything into the FakerPress namespace.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003ETweak - Autoload using Composer properly.\u003C\/p\u003E\u003C\/li\u003E\n\u003C\/ul\u003E"},"0.5.3":{"number":"0.5.3","date":"04 of March 2022","content":"* Fix - Ensure Select2 usage of AJAX search properly encodes on all usages props @TheMMMdev\n* Fix - Ensure Select2 usage of AJAX properly checks for nonces and permissions props @TheMMMdev","html":"\u003Cul\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Ensure Select2 usage of AJAX search properly encodes on all usages props @TheMMMdev\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Ensure Select2 usage of AJAX properly checks for nonces and permissions props @TheMMMdev\u003C\/p\u003E\u003C\/li\u003E\n\u003C\/ul\u003E"}}}}' );
     1<?php return json_decode( '{"headers":{"name":"headers","content":"=== FakerPress ===\nContributors:      bordoni\nTags:              generator, dummy content, lorem ipsun, testing, developer\nRequires at least: 5.5\nTested up to:      6.8.1\nRequires PHP:      8.1\nStable tag:        0.8.0\nLicense:           GPLv2 or later\nLicense URI:       http:\/\/www.gnu.org\/licenses\/gpl-2.0.html\nDonate link:       https:\/\/fakerpress.com\/r\/sponsor\n\nFakerPress is a clean way to generate fake and dummy content to your WordPress, great for developers who need testing\n\n"},"description":{"name":"Description","content":"\n\nWhenever you create a new Theme or Plugin you will always need to create custom data to test whether your plugin is working or not, and as Developers ourselves we had this problem quite alot.\n\nOur goal with this plugin is to fill this gap where you have problem with a good solution both for Developers and for Users of WordPress.\n\n\u003E **Note: This plugin requires PHP 7.4 or higher to be activated.**\n\n[**Checkout our GitHub Repository**](http:\/\/fakerpress.com\/r\/github)\n\n---\n\n= Components Included =\n\n* Posts\n* Custom Post Types\n* Meta Data\n* Featured Image\n* Users\n* Tags\n* Categories\n* Comments\n* Custom Comment Types\n\n= Creating Dummy Content =\nNormally a WordPress developer will need to perform the task of filling up an empty theme with dummy content, and doing this manually can be really time consuming, the main reasons this plugin was create was to speed up this process.\n\n= Random Featured Images =\nCreate randomly generated attachments as the Featured Images for your WordPress dummy content.\n\n= Create random Meta Information =\nWordPress has Meta for Users, Posts, Terms and Comments, FakerPress will allow you to generate custom dummy meta for all four, with *20 types of Data*\n\n= Delete the Content Generated =\nAfter you are done with your testing it should be easy to delete all the content created using FakerPress, now you will be able to do it.\n\n= Generate Random HTML =\nWhen creating dummy posts what you really want is that the HTML is really random so that you might see bugs that an XML import wouldn\u0027t.\n\n= Generate Images in your HTML =\nWhen you are testing your website images are important, so FakerPress will allow you to output Images to your HTML tests.\n\n= Real Browser data on User Comments =\nFor comments our plugin is prepared to generate a real Browser data instead of leaving the field empty.\n\n= Random Terms generation =\nFor creating and assigning the terms you will have a much better tool that will allow you to select which kind of taxonomy you want to assign to your posts, and leaving the randomization to the plugin\u0027s code.\n\n= Real random User profiles =\nIf you fill up your WordPress with any data for the user profiles you might not catch an edge case, this plugin will fill up the fields with data that will really matter in the tests.\n\n= Types of Meta Included =\n* Attachment\n* WP_Query\n* Number\n* Elements\n* Letter\n* Words\n* Text\n* HTML\n* Lexify\n* Asciify\n* Regexify\n* Person\n* Geo Information\n* Company\n* Date\n* TimeZone\n* Email\n* Domain\n* IP\n* Browser User Agent\n\n= Languages =\nWe moved away from _Transifex_ due to the new GlotPress on WordPress.org, so if you want to translate FakerPress to your language please [follow this guidelines](https:\/\/make.wordpress.org\/polyglots\/handbook\/rosetta\/theme-plugin-directories\/#translating-themes-plugins).\n\n= See room for improvement? =\n\nGreat! There are several ways you can get involved to help make FakerPress better:\n\n1. **Report Bugs:** If you find a bug, error or other problem, please report it! You can do this by [creating a new topic](http:\/\/wordpress.org\/support\/plugin\/fakerpress) in the plugin forum. Once a developer can verify the bug by reproducing it, they will create an official bug report in GitHub where the bug will be worked on.\n2. **Suggest New Features:** Have an awesome idea? Please share it! Simply [create a new topic](http:\/\/wordpress.org\/support\/plugin\/fakerpress) in the plugin forum to express your thoughts on why the feature should be included and get a discussion going around your idea.\n3. **Issue Pull Requests:** If you\u0027re a developer, the easiest way to get involved is to help out on [issues already reported](https:\/\/github.com\/bordoni\/fakerpress\/issues) in GitHub. Be sure to check out the [contributing guide](https:\/\/github.com\/bordoni\/fakerpress\/blob\/master\/contributing.md) for developers.\n\nThank you for wanting to make FakerPress better for everyone! [We salute you](https:\/\/www.youtube.com\/watch?v=8fPf6L0XNvM).\n\n"},"changelog":{"name":"Changelog","content":"\n\n= 0.8.0 \u0026mdash; 20 of May 2025 =\n\n* Version - Update dependency `cakephp\/chronos` to `3.1.0`\n* Version - Update PHP min version to `8.1+`\n* Fix - Resolve PHP `8.4+` problems specially arounnd incompatibility with Chronos and notices.\n\n= 0.7.2 \u0026mdash; 18 of May 2025 =\n\n* Fix - Resolve all fatals related to compatibility with version of Faker `1.24+`.\n* Fix - Resolve some incompatibilities with WP Script build tools.\n\n= 0.7.1 \u0026mdash; 18 of May 2025 =\n\n* Fix - Move the registration of the menus to avoid problems with `_load_textdomain_just_in_time()` notices\n* Fix - Resolve problems with `count()` applying to a String instead of an Array for PHP 8.1+\n* Fix - Resolve fatals for newChronos being a bad string replacement.\n\n= 0.7.0 \u0026mdash; 16 of May 2025 =\n\n* Version - Update dependency `fakerphp\/faker` to `1.24`\n* Version - Update dependency `lucatume\/di52` to `0.4`\n* Tweak - Modified date handling from using `Carbon` to use `Chronos`.\n* Fix - Improved password for the randomized Users created, prevents weird scenarios with faked users allowing brute-force login. Props @rinatkhaziev\n* Fix - Prevent fatals related to `$min` param on Meta Value generation for PHP 8.1+. Props @kubiq\n\n= 0.6.6 \u0026mdash; 26 of April 2024 =\n\n* Fix - Prevent notices related to deprecated usage of Faker methods that were being called as properties.\n* Fix - Prevent fatals related to bad typecasting of Faker methods used for meta generation. props @helgatheviking\n\n= 0.6.5 \u0026mdash; 26 of April 2024 =\n\n* Fix - Ensure meta generation for Users, Terms and Comments work since changes made on version `0.6.2`. props @helgatheviking\n\n= 0.6.4 \u0026mdash; 21 of April 2024 =\n\n* Fix - Ensure that Faker is also included via Strauss, to prevent conflicts with other plugins.\n* Fix - Resolve Fatal where trying to create posts, comments or terms would fail because of missing classes.\n\n= 0.6.3 \u0026mdash; 21 of April 2024 =\n\n* Fix - Prevent fatal errors because of malformed composer autoload files.\n\n= 0.6.2 \u0026mdash; 21 of April 2024 =\n\n* Version - Updated composer dependency `fakerphp\/faker` to version `1.23`.\n* Feature - Include consistent user generation, to avoid users feeling a disjointed. props @helgatheviking\n* Tweak - Include the ability to regenerate module data, allowing us to fetch values from earlier generations.\n* Tweak - Include properly use Composer for autoloading and dependencies without conflicting with other plugins.\n* Tweak - Include `lucatume\/di52` and `nesbot\/carbon` Strauss dependencies, which prevents conflicts with other plugins.\n* Fix - Switch from using Placeholder.com to Placehold.co, as the first one was not working properly anymore. props @cgarofalo\n* Fix - Searching terms nonce had a typo, preventing terms search from working as expected. props @cyrusdavid\n* Fix - Prevent namespace problems with nonexistent classes, specially around Exceptions.\n* Fix - Resolve a problem with Numbers Meta throwing errors on PHP 8.0+ [#168]\n\n= 0.6.1 \u0026mdash; 04 of April 2023 =\n\n* Requirement - PHP Version 7.4 required for usage of FakerPress, important step to allow further improvements and tests.\n* Version - Updated composer dependency `lucatume\/di52` to version `3.3.1`.\n* Version - Updated composer dependency `fakerphp\/faker` to version `1.21`.\n* Version - Updated composer dependency `nesbot\/carbon` to version `2.66`.\n* Fix - Resolve some errors happening with Carbon and version 8.2 of PHP.\n\n= 0.6.0 \u0026mdash; 30 of March 2022 =\n\n* Requirement - PHP Version 7.1 required for usage of FakerPress, important step to allow further improvements and tests.\n* Feature - Modifications to the internal Modules of FakerPress to enable future work around WP-CLI.\n* Feature - Include a new way to handle Administration Pages, included here to enable future work.\n* Enhancement - Modifications to Select2 Styles for better accessibility usage.\n* Tweak - Faker version dependency updated from `fzaninotto\/Faker` to `fakerphp\/Faker\/`.\n* Tweak - Move everything into the FakerPress namespace.\n* Tweak - Autoload using Composer properly.\n\n= 0.5.3 \u0026mdash; 04 of March 2022 =\n\n* Fix - Ensure Select2 usage of AJAX search properly encodes on all usages props @TheMMMdev\n* Fix - Ensure Select2 usage of AJAX properly checks for nonces and permissions props @TheMMMdev\n\n= 0.5.2 \u0026mdash; 27 of January 2022 =\n\n* Feature: Proper changelog page for users trying to figure out what has changed in the latest version of FakerPress.\n* Feature: Excerpt size field added to ensure better control over Post generation prop @gtsantos\n* Tweak: jQuery 3.5.X compatibility\n* Fix: Prevent warning around post_excerpt usage introduced earlier on in the year. props @pattisahusiwa\n* Fix: One more PHP 8 compatibility problem related to the generation of passwords props @DumahX\n* Fix: Prevent PHP 8 from throwing a warning because of unnecessary `unlink()` call for attachments props @wpuzman\n* Fix: Resolve problems around failed inline images that were unavailable which would cause a PHP Warning.\n\n= 0.5.1 \u0026mdash; 05 of January 2021 =\n\n* Feature: Completely change folder structure to comply with [PSR-4](https:\/\/www.php-fig.org\/psr\/psr-4\/) autoloading with namespaces.\n* Feature: Included a Fields API to more easily generate Fields for controlling fields used in the admin pages.\n* Feature: Included a Template class to allow better separation of HTML and PHP files.\n* Tweak: Include compatibility with PHP 8+\n* Tweak: More well structured `composer.json` and using it\u0027s autoloader.\n* Tweak: All PHP files now live inside of `src` folder.\n* Tweak: Moved all files to use the `[]` array syntax.\n* Tweak: GitHub repository no longer tracks the `vendor` folder.\n* Fix: Correctly order the `fp_array_get` params with it\u0027s usage props @henrikwirth.\n* Fix: Make sure WordPress 5.6+ administration proper display fields.\n* Fix: Menu icon is properly displayed on version of WordPress 5.5 or higher\n\n= 0.5.0 \u0026mdash; 09 of November, 2019 =\n\n* Feature: Removed 500px as a image provider as that source was deprecated a while ago.\n* Fix: Properly handle downloading of images into WordPress, which makes this a lot safer and faster.\n* Fix: Resolved the problem where images from the Meta Attachment were been generated with 0x0 size and breaking the attachment.\n* Fix: Removed 500px as a image provider as that source was deprecated a while ago.\n* Fix: Moved from Unplash.it to their new name as Lorem Picsum.\n* Tweak: Started adding proper docblocks to the new methods. Note it will take a couple versions to have all methods with proper docblocks.\n* Tweak: Control timeout of image download with filter `fakerpress.module.attachment.download_url_timeout` defaulting to 10 seconds per attachment.\n* Tweak: Update required version of PHP to 5.6 to be more along the requirements of WordPress.\n* Tweak: Test and update the version of WordPress FakerPress was tested up to, now on 5.3.\n* Tweak: Updated the version of fzaninotto\/faker (v1.6.0 =\u003E v1.8.0)\n* Tweak: Updated the version of nesbot\/carbon (1.21.0 =\u003E 1.39.1)\n\n= 0.4.11 \u0026mdash; 25 of February, 2018 =\n\n* Fix: Prevent fatals from oversight with Namespace and Classnames for User and Post generation \u0026mdash; Thanks [@radgh](https:\/\/wordpress.org\/support\/topic\/fakerpress-generate-users-fails\/) \u0026 [@johny-dotpad](https:\/\/wordpress.org\/support\/topic\/post-generation-fails\/)\n* Fix: Rollback change to `file_get_contents` it was making peoples servers hang to long \u0026mdash; Thanks [@bilimokur](https:\/\/wordpress.org\/support\/topic\/most-images-are-corrupted\/)\n\n= 0.4.10 \u0026mdash; 11 of February, 2018 =\n\n* Feature: Added size control to Post Content, Comment Content and User Description\n* Fix: On image and attachment download we try one more time using `file_get_contents` \u0026mdash; Thanks [@lazlo-toth](https:\/\/wordpress.org\/support\/topic\/most-of-the-featured-image-links-appear-to-be-invalid\/)\n* Fix: Resolve Quantity Min and Max fields weird interaction \u0026mdash; Thanks [@rahmantanvir](https:\/\/github.com\/bordoni\/fakerpress\/issues\/124)\n\n= 0.4.9 \u0026mdash; 07 of August, 2017 =\n\n* Feature: Allow Attachments to be generated with a given Width and Height range \u0026mdash; Thanks [@COLABORATI](https:\/\/github.com\/bordoni\/fakerpress\/issues\/86)\n* Feature: Generate `post_excerpt` for Posts (how I forgot that is beyond me) \u0026mdash; Thanks [@njbarrett](https:\/\/github.com\/bordoni\/fakerpress\/issues\/104)\n* Fix: Meta field rules were not respecting Configurations due to a JavaScript bug on indexing the fields \u0026mdash; Thanks [@ckpicker](https:\/\/github.com\/bordoni\/fakerpress\/issues\/115)\n* Fix: Resolve problems where attachments wouldn\u0027t get setup correctly and throw an Empty Message \u0026mdash; Thanks [@r083r7 and @oyvind_skjelstad](https:\/\/wordpress.org\/support\/topic\/featured-image-not-showing-up-6)\n* Fix: Allow Term Meta to generate the fields correctly again \u0026mdash; Thanks [@stratboy](https:\/\/github.com\/bordoni\/fakerpress\/issues\/105)\n* Tweak: Prevent `_encloseme` and `_pingme` for FakerPress generated Posts\n\n= 0.4.8 \u0026mdash; 18 of July, 2017 =\n\n* Feature: Now Comments can be generated with different types, allowing for WooCommerce Notes for example - Thanks [@dibbyo456](https:\/\/wordpress.org\/support\/topic\/can-i-create-custom-comments\/)\n* Feature: Comments for Custom Post Types - Thanks [@jasondevine](https:\/\/github.com\/bordoni\/fakerpress\/issues\/109)\n* Tweak: Added two new filters to Filter Meta Value `fakerpress.module.meta.value` and `fakerpress.module.meta.{$key}.value` - Thanks [@Mte90](https:\/\/github.com\/bordoni\/fakerpress\/pull\/111)\n* Fix: Resolve problems on failed Meta generation - Thanks [@Mte90](https:\/\/github.com\/bordoni\/fakerpress\/pull\/110)\n* Fix: Typo on Provider text for Attachment Meta - Thanks [@codiceovvio](https:\/\/github.com\/bordoni\/fakerpress\/pull\/103)\n\n= 0.4.7 \u0026mdash; 2 of October, 2016 =\n\n* Feature: Image Attachment Meta Field to allow more Flexibility all around the plugin\n\n= 0.4.6 \u0026mdash; 14 of June, 2016 =\n\n* Fix: Post Meta and taxonomy is finally working again \u0026mdash; Thanks [@peachey_a](https:\/\/wordpress.org\/support\/topic\/generated-posts-not-assigned-categories) and [@zoeitsolutions](https:\/\/wordpress.org\/support\/topic\/user-meta-not-being-generated)\n* Fix: Allow Meta Number generation using any type of range, doesn\u0027t limit from 0 to 9\n\n= 0.4.5 \u0026mdash; 11 of June, 2016 =\n\n* Fix: Users Module was using Post Meta methods on flag related methods, preventing the users to be deleted when \u0022Let it Go!\u0022 \u0026mdash; Thanks [@derpixler](https:\/\/github.com\/bordoni\/fakerpress\/issues\/84)\n* Fix: Taxonomy and Meta Modules had a compatibility problem with Faker, preveting users to use Meta and Taxonomy Properly \u0026mdash; Thanks [@rayrutjes](https:\/\/github.com\/bordoni\/fakerpress\/issues\/94)\n* Tweak: Add a better description for a few fields\n* Tweak: Include [latest code from Faker](https:\/\/github.com\/fzaninotto\/Faker) version \u003E 1.6.0\n\n= 0.4.4 \u0026mdash; 1 of April, 2016 =\n\n* Feature: Address Meta templating now allows you to fetch Country ABBR and Code \u0026mdash; Thanks [@kirilisa](https:\/\/wordpress.org\/support\/topic\/excellent-3360)\n* Tweak: Include [latest code from Faker](https:\/\/github.com\/fzaninotto\/Faker) version \u003E 1.5.0\n* Tweak: WP_Query Meta for attachments is a little bit easier now, prediction of forgotten `post_status`\n* Tweak: Make the Post Parent selection easier to know which posts by showing more information on the items \u0026mdash; Thanks [@fxbernard](https:\/\/github.com\/bordoni\/fakerpress\/issues\/81)\n* Fix: Get some missing Text Domains working \u0026mdash; Thanks [@ginsterbusch](https:\/\/github.com\/bordoni\/fakerpress\/issues\/77)\n\n= 0.4.3 \u0026mdash; 1 of March, 2016 =\n\n* Feature: No more Hot-linking external sites on Content Images \u0026mdash; Thanks [b0rg](https:\/\/profiles.wordpress.org\/b0rg) + [mvaneijgen](https:\/\/profiles.wordpress.org\/mvaneijgen) + [okvee](https:\/\/profiles.wordpress.org\/okvee)\n* Tweak: Use `wp_remote_get` to fetch external images \u0026mdash; Thanks [revaxarts](https:\/\/twitter.com\/revaxarts)\n* Tweak: Improve how we handle the Deletes to make sure it doesn\u0027t delete all your site \u0026mdash; Thanks [Paul Mckay](https:\/\/twitter.com\/McKay_1988\/status\/700299519825723392)\n* Fix: Prevent Notices from happening when no Image providers were selected\n\n= 0.4.2 \u0026mdash; 9 of November, 2015 =\n\n* Feature: Include meta for Terms for WordPress 4.4 and Up\n* Tweak: Include a more granular control over Taxonomy selector for Posts\n* Fix: CSS changes for WordPress 4.4\n\n= 0.4.1 \u0026mdash; 24 of September, 2015 =\n\n* Tweak: Improve Modules code in general, if you have custom code based on Modules please check ([#71](https:\/\/github.com\/bordoni\/fakerpress\/pull\/71))\n* Fix: Generate button was locking after a warning for trying a bad request\n* Fix: Improved Modules JavaScript to prevent duplicated arguments on AJAX requests \u0026mdash; Thanks [Jonathan Brinley](https:\/\/profiles.wordpress.org\/jbrinley\/)\n\n= 0.4.0 \u0026mdash; 21 of September, 2015 =\n\n* Feature: Now Modules use AJAX to fake, AKA no more timeouts for big dummy creation\n* Fix: handle WP_Error on term creation, avoids fatal errors if the term already exists \u0026mdash; Thanks [Jonathan Brinley](https:\/\/profiles.wordpress.org\/jbrinley\/)\n\n= 0.3.3 \u0026mdash; 10 of June, 2015 =\n\n* Tweak: Our menus and submenus no longer require JavaScript to work\n* Tweak: Featured Images now are linked to the post using the `post_parent` column \u0026mdash; Reported by [Bruno DC](https:\/\/profiles.wordpress.org\/decarvalho_bruno)\n* Fix: Dates on Meta fields are fully working again \u0026mdash; Thanks [Ethan Clevenger](https:\/\/profiles.wordpress.org\/eclev91)\n\n= 0.3.2 \u0026mdash; 25 of May, 2015 =\n\n* New: Including LoremPixel as a Image Provider \u0026mdash; Thanks [examinedliving](https:\/\/github.com\/examinedliving)\n* Fix: A few JavaScript\/jQuery tweeks for better Select2 Handling on Dates\n* Fix: Intervals now have a better Handling for non-timed Strings \u0026mdash; Thanks [alfiemx_](https:\/\/profiles.wordpress.org\/alfiemx_)\n* Fix: Better verification of Carbon inclusion \u0026mdash; Thanks [Frankie Jarrett](https:\/\/profiles.wordpress.org\/fjarrett\/)\n* Fix: Closures now using self variables better, prevents Fatal Error \u0026mdash; Thanks [fccoelho7](https:\/\/profiles.wordpress.org\/fccoelho7\/)\n\n= 0.3.1 \u0026mdash; 02 of May, 2015 =\n\n* Fix: Date Meta Field is now working as expected\n* Fix: Empty meta fields don\u0027t throw Fatal Errors anymore \u0026mdash; Thanks [Jeffrey Carandang](https:\/\/profiles.wordpress.org\/phpbits\/)\n\n= 0.3.0 \u0026mdash; 01 of May, 2015 =\n\n* New: Now you will be able to generate Custom dummy Meta for your Posts, Users and Comments\n\n= 0.2.2 \u0026mdash; 15 of April, 2015 =\n\n* New: 500px as a Image provider ( You will need a Customer App Key )\n* Tweak: New formula for Taxonomy randomization for Posts ( with new filters )\n\n= 0.2.1 \u0026mdash; 02 of April, 2015 =\n\n* Fix: User generator now working again (sorry about that)\n\n= 0.2.0 \u0026mdash; 01 of April, 2015 =\n\n* New: Featured Images is now an Option on our Plugin\n* New: Handling of Post Meta, still under the hood but preparation for the next versions\n\n= 0.1.6 \u0026mdash; 07 of March, 2015 =\n\n* Fix: Prevent Carbon to Fatal error if trying to be included twice ([#50](https:\/\/github.com\/bordoni\/fakerpress\/issues\/50))\n* Tweak: Better checking for the content flag when deleting\n\n= 0.1.5 \u0026mdash; 03 September, 2014 =\n\n* New: Allow post Parent to be chosen on the Admin Form ([#35](https:\/\/github.com\/bordoni\/fakerpress\/issues\/35))\n* New: Now allow Image to be used in HTML, with Placehold.it ([#38](https:\/\/github.com\/bordoni\/fakerpress\/issues\/38))\n* Tweak: Allow users to choose which HTML tags will be used ([#37](https:\/\/github.com\/bordoni\/fakerpress\/issues\/37))\n* Tweak: User Select2 now uses AJAX to prevent bugs on bigger databases ([#43](https:\/\/github.com\/bordoni\/fakerpress\/issues\/43))\n* Tweak: Now you can select a range of items to be randomized, instead of always having to input a single number ([#44](https:\/\/github.com\/bordoni\/fakerpress\/issues\/44))\n\n= 0.1.4 \u0026mdash; 15 of August, 2014 =\n\n* New: Delete all content created by Fakerpress ([#26](https:\/\/github.com\/bordoni\/fakerpress\/issues\/26))\n* New: Allow users to control `comment_status` on Posts ([#26](https:\/\/github.com\/bordoni\/fakerpress\/issues\/26))\n* New: Predefined interval set of dates ([#21](https:\/\/github.com\/bordoni\/fakerpress\/issues\/21))\n* Tweak: Prevent the user from selecting a bad combination of date fields ([#20](https:\/\/github.com\/bordoni\/fakerpress\/issues\/20))\n\n= 0.1.3 \u0026mdash; 25 of June, 2014 =\n\n* Fixing a problem where the UI folder was not included in the final version\n\n= 0.1.2 \u0026mdash; 24 of June, 2014 =\n\n* New: Admin messages for all pages ([#10](https:\/\/github.com\/bordoni\/fakerpress\/issues\/10))\n* New: Select Date range for Comments and Posts ([#11](https:\/\/github.com\/bordoni\/fakerpress\/issues\/11))\n* New: Select Author sampling group for Posts ([#11](https:\/\/github.com\/bordoni\/fakerpress\/issues\/11))\n* New: Roles sampling group for Users ([#13](https:\/\/github.com\/bordoni\/fakerpress\/issues\/13))\n* New: Taxonomies sampling group for Terms ([#13](https:\/\/github.com\/bordoni\/fakerpress\/issues\/13))\n* New: Selection of Post Type for Posts ([#13](https:\/\/github.com\/bordoni\/fakerpress\/issues\/13))\n* New: Selection of Terms sampling group for Posts ([#13](https:\/\/github.com\/bordoni\/fakerpress\/issues\/13))\n* Tweak: Select2 usage to improve fields ([#13](https:\/\/github.com\/bordoni\/fakerpress\/issues\/13))\n* Fix: `admin_title` been overwritten ([#14](https:\/\/github.com\/bordoni\/fakerpress\/issues\/14))\n\n= 0.1.1 \u0026mdash; 17 of June, 2014 =\n\n* Fatal Error generate by a missing file Carbon related fixed\n\n= 0.1.0 \u0026mdash; 17 of June, 2014 =\n\n* First initial concept of using [Faker](https:\/\/github.com\/fzaninotto\/Faker) to generate data on WordPress","versions":{"0.8.0":{"number":"0.8.0","date":"20 of May 2025","content":"* Version - Update dependency `cakephp\/chronos` to `3.1.0`\n* Version - Update PHP min version to `8.1+`\n* Fix - Resolve PHP `8.4+` problems specially arounnd incompatibility with Chronos and notices.","html":"\u003Cul\u003E\n\u003Cli\u003E\u003Cp\u003EVersion - Update dependency \u003Ccode\u003Ecakephp\/chronos\u003C\/code\u003E to \u003Ccode\u003E3.1.0\u003C\/code\u003E\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EVersion - Update PHP min version to \u003Ccode\u003E8.1+\u003C\/code\u003E\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Resolve PHP \u003Ccode\u003E8.4+\u003C\/code\u003E problems specially arounnd incompatibility with Chronos and notices.\u003C\/p\u003E\u003C\/li\u003E\n\u003C\/ul\u003E"},"0.7.2":{"number":"0.7.2","date":"18 of May 2025","content":"* Fix - Resolve all fatals related to compatibility with version of Faker `1.24+`.\n* Fix - Resolve some incompatibilities with WP Script build tools.","html":"\u003Cul\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Resolve all fatals related to compatibility with version of Faker \u003Ccode\u003E1.24+\u003C\/code\u003E.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Resolve some incompatibilities with WP Script build tools.\u003C\/p\u003E\u003C\/li\u003E\n\u003C\/ul\u003E"},"0.7.1":{"number":"0.7.1","date":"18 of May 2025","content":"* Fix - Move the registration of the menus to avoid problems with `_load_textdomain_just_in_time()` notices\n* Fix - Resolve problems with `count()` applying to a String instead of an Array for PHP 8.1+\n* Fix - Resolve fatals for newChronos being a bad string replacement.","html":"\u003Cul\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Move the registration of the menus to avoid problems with \u003Ccode\u003E_load_textdomain_just_in_time()\u003C\/code\u003E notices\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Resolve problems with \u003Ccode\u003Ecount()\u003C\/code\u003E applying to a String instead of an Array for PHP 8.1+\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Resolve fatals for newChronos being a bad string replacement.\u003C\/p\u003E\u003C\/li\u003E\n\u003C\/ul\u003E"},"0.7.0":{"number":"0.7.0","date":"16 of May 2025","content":"* Version - Update dependency `fakerphp\/faker` to `1.24`\n* Version - Update dependency `lucatume\/di52` to `0.4`\n* Tweak - Modified date handling from using `Carbon` to use `Chronos`.\n* Fix - Improved password for the randomized Users created, prevents weird scenarios with faked users allowing brute-force login. Props @rinatkhaziev\n* Fix - Prevent fatals related to `$min` param on Meta Value generation for PHP 8.1+. Props @kubiq","html":"\u003Cul\u003E\n\u003Cli\u003E\u003Cp\u003EVersion - Update dependency \u003Ccode\u003Efakerphp\/faker\u003C\/code\u003E to \u003Ccode\u003E1.24\u003C\/code\u003E\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EVersion - Update dependency \u003Ccode\u003Elucatume\/di52\u003C\/code\u003E to \u003Ccode\u003E0.4\u003C\/code\u003E\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003ETweak - Modified date handling from using \u003Ccode\u003ECarbon\u003C\/code\u003E to use \u003Ccode\u003EChronos\u003C\/code\u003E.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Improved password for the randomized Users created, prevents weird scenarios with faked users allowing brute-force login. Props @rinatkhaziev\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Prevent fatals related to \u003Ccode\u003E$min\u003C\/code\u003E param on Meta Value generation for PHP 8.1+. Props @kubiq\u003C\/p\u003E\u003C\/li\u003E\n\u003C\/ul\u003E"},"0.6.6":{"number":"0.6.6","date":"26 of April 2024","content":"* Fix - Prevent notices related to deprecated usage of Faker methods that were being called as properties.\n* Fix - Prevent fatals related to bad typecasting of Faker methods used for meta generation. props @helgatheviking","html":"\u003Cul\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Prevent notices related to deprecated usage of Faker methods that were being called as properties.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Prevent fatals related to bad typecasting of Faker methods used for meta generation. props @helgatheviking\u003C\/p\u003E\u003C\/li\u003E\n\u003C\/ul\u003E"},"0.6.5":{"number":"0.6.5","date":"26 of April 2024","content":"* Fix - Ensure meta generation for Users, Terms and Comments work since changes made on version `0.6.2`. props @helgatheviking","html":"\u003Cul\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Ensure meta generation for Users, Terms and Comments work since changes made on version \u003Ccode\u003E0.6.2\u003C\/code\u003E. props @helgatheviking\u003C\/p\u003E\u003C\/li\u003E\n\u003C\/ul\u003E"},"0.6.4":{"number":"0.6.4","date":"21 of April 2024","content":"* Fix - Ensure that Faker is also included via Strauss, to prevent conflicts with other plugins.\n* Fix - Resolve Fatal where trying to create posts, comments or terms would fail because of missing classes.","html":"\u003Cul\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Ensure that Faker is also included via Strauss, to prevent conflicts with other plugins.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Resolve Fatal where trying to create posts, comments or terms would fail because of missing classes.\u003C\/p\u003E\u003C\/li\u003E\n\u003C\/ul\u003E"},"0.6.3":{"number":"0.6.3","date":"21 of April 2024","content":"* Fix - Prevent fatal errors because of malformed composer autoload files.","html":"\u003Cul\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Prevent fatal errors because of malformed composer autoload files.\u003C\/p\u003E\u003C\/li\u003E\n\u003C\/ul\u003E"},"0.6.2":{"number":"0.6.2","date":"21 of April 2024","content":"* Version - Updated composer dependency `fakerphp\/faker` to version `1.23`.\n* Feature - Include consistent user generation, to avoid users feeling a disjointed. props @helgatheviking\n* Tweak - Include the ability to regenerate module data, allowing us to fetch values from earlier generations.\n* Tweak - Include properly use Composer for autoloading and dependencies without conflicting with other plugins.\n* Tweak - Include `lucatume\/di52` and `nesbot\/carbon` Strauss dependencies, which prevents conflicts with other plugins.\n* Fix - Switch from using Placeholder.com to Placehold.co, as the first one was not working properly anymore. props @cgarofalo\n* Fix - Searching terms nonce had a typo, preventing terms search from working as expected. props @cyrusdavid\n* Fix - Prevent namespace problems with nonexistent classes, specially around Exceptions.\n* Fix - Resolve a problem with Numbers Meta throwing errors on PHP 8.0+ [#168]","html":"\u003Cul\u003E\n\u003Cli\u003E\u003Cp\u003EVersion - Updated composer dependency \u003Ccode\u003Efakerphp\/faker\u003C\/code\u003E to version \u003Ccode\u003E1.23\u003C\/code\u003E.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFeature - Include consistent user generation, to avoid users feeling a disjointed. props @helgatheviking\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003ETweak - Include the ability to regenerate module data, allowing us to fetch values from earlier generations.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003ETweak - Include properly use Composer for autoloading and dependencies without conflicting with other plugins.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003ETweak - Include \u003Ccode\u003Elucatume\/di52\u003C\/code\u003E and \u003Ccode\u003Enesbot\/carbon\u003C\/code\u003E Strauss dependencies, which prevents conflicts with other plugins.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Switch from using Placeholder.com to Placehold.co, as the first one was not working properly anymore. props @cgarofalo\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Searching terms nonce had a typo, preventing terms search from working as expected. props @cyrusdavid\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Prevent namespace problems with nonexistent classes, specially around Exceptions.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Resolve a problem with Numbers Meta throwing errors on PHP 8.0+ [#168]\u003C\/p\u003E\u003C\/li\u003E\n\u003C\/ul\u003E"},"0.6.1":{"number":"0.6.1","date":"04 of April 2023","content":"* Requirement - PHP Version 7.4 required for usage of FakerPress, important step to allow further improvements and tests.\n* Version - Updated composer dependency `lucatume\/di52` to version `3.3.1`.\n* Version - Updated composer dependency `fakerphp\/faker` to version `1.21`.\n* Version - Updated composer dependency `nesbot\/carbon` to version `2.66`.\n* Fix - Resolve some errors happening with Carbon and version 8.2 of PHP.","html":"\u003Cul\u003E\n\u003Cli\u003E\u003Cp\u003ERequirement - PHP Version 7.4 required for usage of FakerPress, important step to allow further improvements and tests.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EVersion - Updated composer dependency \u003Ccode\u003Elucatume\/di52\u003C\/code\u003E to version \u003Ccode\u003E3.3.1\u003C\/code\u003E.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EVersion - Updated composer dependency \u003Ccode\u003Efakerphp\/faker\u003C\/code\u003E to version \u003Ccode\u003E1.21\u003C\/code\u003E.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EVersion - Updated composer dependency \u003Ccode\u003Enesbot\/carbon\u003C\/code\u003E to version \u003Ccode\u003E2.66\u003C\/code\u003E.\u003C\/p\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cp\u003EFix - Resolve some errors happening with Carbon and version 8.2 of PHP.\u003C\/p\u003E\u003C\/li\u003E\n\u003C\/ul\u003E"}}}}' );
  • fakerpress/tags/0.8.0/src/functions/container.php

    r3296016 r3297704  
    6262 *                                                    construction.
    6363 */
    64 function singleton( $slug, $class, array $after_build_methods = null ) {
     64function singleton( $slug, $class, ?array $after_build_methods = null ) {
    6565    Container::init()->singleton( $slug, $class, $after_build_methods );
    6666}
     
    126126 *                                                    will be called each time after the instance construction.
    127127 */
    128 function bind( $slug, $class, array $after_build_methods = null ) {
     128function bind( $slug, $class, ?array $after_build_methods = null ) {
    129129    Container::init()->bind( $slug, $class, $after_build_methods );
    130130}
  • fakerpress/tags/0.8.0/vendor-prefixed/autoload.php

    r3296016 r3297704  
    2020require_once __DIR__ . '/composer/autoload_real.php';
    2121
    22 return ComposerAutoloaderInitd4e0679c57019ad4f73ecb3ba581bb5c::getLoader();
     22return ComposerAutoloaderInit5dc28f99f9a111df9987bee394b31be9::getLoader();
  • fakerpress/tags/0.8.0/vendor-prefixed/cakephp/chronos/src/Chronos.php

    r3296016 r3297704  
    1616
    1717use DateInterval;
     18use DatePeriod;
    1819use DateTimeImmutable;
     20use DateTimeInterface;
    1921use DateTimeZone;
     22use InvalidArgumentException;
     23use RuntimeException;
     24use Stringable;
    2025
    2126/**
     
    2732 * @property-read int $year
    2833 * @property-read int $yearIso
    29  * @property-read int $month
    30  * @property-read int $day
    31  * @property-read int $hour
    32  * @property-read int $minute
    33  * @property-read int $second
    34  * @property-read int $micro
    35  * @property-read int $microsecond
     34 * @property-read int<1, 12> $month
     35 * @property-read int<1, 31> $day
     36 * @property-read int<0, 23> $hour
     37 * @property-read int<0, 59> $minute
     38 * @property-read int<0, 59> $second
     39 * @property-read int<0, 999999> $micro
     40 * @property-read int<0, 999999> $microsecond
    3641 * @property-read int $timestamp seconds since the Unix Epoch
    3742 * @property-read \DateTimeZone $timezone the current timezone
    3843 * @property-read \DateTimeZone $tz alias of timezone
    39  * @property-read int $dayOfWeek 1 (for Monday) through 7 (for Sunday)
    40  * @property-read int $dayOfYear 0 through 365
    41  * @property-read int $weekOfMonth 1 through 5
    42  * @property-read int $weekOfYear ISO-8601 week number of year, weeks starting on Monday
    43  * @property-read int $daysInMonth number of days in the given month
     44 * @property-read int<1, 7> $dayOfWeek 1 (for Monday) through 7 (for Sunday)
     45 * @property-read int<0, 365> $dayOfYear 0 through 365
     46 * @property-read int<1, 5> $weekOfMonth 1 through 5
     47 * @property-read int<1, 53> $weekOfYear ISO-8601 week number of year, weeks starting on Monday
     48 * @property-read int<1, 31> $daysInMonth number of days in the given month
    4449 * @property-read int $age does a diffInYears() with default parameters
    45  * @property-read int $quarter the quarter of this instance, 1 - 4
     50 * @property-read int<1, 4> $quarter the quarter of this instance, 1 - 4
     51 * @property-read int<1, 2> $half the half of the year, with 1 for months Jan...Jun and 2 for Jul...Dec.
    4652 * @property-read int $offset the timezone offset in seconds from UTC
    4753 * @property-read int $offsetHours the timezone offset in hours from UTC
     
    5157 * @property-read string $timezoneName
    5258 * @property-read string $tzName
     59 * @psalm-immutable
     60 * @psalm-consistent-constructor
    5361 */
    54 class Chronos extends DateTimeImmutable implements ChronosInterface
     62class Chronos extends DateTimeImmutable implements Stringable
    5563{
    56     use Traits\ComparisonTrait;
    57     use Traits\DifferenceTrait;
    58     use Traits\FactoryTrait;
    59     use Traits\FormattingTrait;
    60     use Traits\MagicPropertyTrait;
    61     use Traits\ModifierTrait;
    62     use Traits\RelativeKeywordTrait;
    63     use Traits\TimezoneTrait;
    64 
    65     /**
    66      * A test ChronosInterface instance to be returned when now instances are created
     64    use FormattingTrait;
     65
     66    /**
     67     * @var int
     68     */
     69    public const MONDAY = 1;
     70
     71    /**
     72     * @var int
     73     */
     74    public const TUESDAY = 2;
     75
     76    /**
     77     * @var int
     78     */
     79    public const WEDNESDAY = 3;
     80
     81    /**
     82     * @var int
     83     */
     84    public const THURSDAY = 4;
     85
     86    /**
     87     * @var int
     88     */
     89    public const FRIDAY = 5;
     90
     91    /**
     92     * @var int
     93     */
     94    public const SATURDAY = 6;
     95
     96    /**
     97     * @var int
     98     */
     99    public const SUNDAY = 7;
     100
     101    /**
     102     * @var int
     103     */
     104    public const YEARS_PER_CENTURY = 100;
     105
     106    /**
     107     * @var int
     108     */
     109    public const YEARS_PER_DECADE = 10;
     110
     111    /**
     112     * @var int
     113     */
     114    public const MONTHS_PER_YEAR = 12;
     115
     116    /**
     117     * @var int
     118     */
     119    public const MONTHS_PER_QUARTER = 3;
     120
     121    /**
     122     * @var int
     123     */
     124    public const WEEKS_PER_YEAR = 52;
     125
     126    /**
     127     * @var int
     128     */
     129    public const DAYS_PER_WEEK = 7;
     130
     131    /**
     132     * @var int
     133     */
     134    public const HOURS_PER_DAY = 24;
     135
     136    /**
     137     * @var int
     138     */
     139    public const MINUTES_PER_HOUR = 60;
     140
     141    /**
     142     * @var int
     143     */
     144    public const SECONDS_PER_MINUTE = 60;
     145
     146    /**
     147     * Default format to use for __toString method when type juggling occurs.
     148     *
     149     * @var string
     150     */
     151    public const DEFAULT_TO_STRING_FORMAT = 'Y-m-d H:i:s';
     152
     153    /**
     154     * A test Chronos instance to be returned when now instances are created
    67155     *
    68156     * There is a single test now for all date/time classes provided by Chronos.
    69157     * This aims to emulate stubbing out 'now' which is a single global fact.
    70158     *
    71      * @var \FakerPress\ThirdParty\Cake\Chronos\ChronosInterface|null
    72      */
    73     protected static $testNow;
     159     * @var \FakerPress\ThirdParty\Cake\Chronos\Chronos|null
     160     */
     161    protected static ?Chronos $testNow = null;
    74162
    75163    /**
     
    78166     * @var string
    79167     */
    80     protected static $toStringFormat = ChronosInterface::DEFAULT_TO_STRING_FORMAT;
     168    protected static string $toStringFormat = self::DEFAULT_TO_STRING_FORMAT;
     169
     170    /**
     171     * Days of weekend
     172     *
     173     * @var array
     174     */
     175    protected static array $weekendDays = [Chronos::SATURDAY, Chronos::SUNDAY];
     176
     177    /**
     178     * Names of days of the week.
     179     *
     180     * @var array
     181     */
     182    protected static array $days = [
     183        Chronos::MONDAY => 'Monday',
     184        Chronos::TUESDAY => 'Tuesday',
     185        Chronos::WEDNESDAY => 'Wednesday',
     186        Chronos::THURSDAY => 'Thursday',
     187        Chronos::FRIDAY => 'Friday',
     188        Chronos::SATURDAY => 'Saturday',
     189        Chronos::SUNDAY => 'Sunday',
     190    ];
     191
     192    /**
     193     * First day of week
     194     *
     195     * @var int
     196     */
     197    protected static int $weekStartsAt = Chronos::MONDAY;
     198
     199    /**
     200     * Last day of week
     201     *
     202     * @var int
     203     */
     204    protected static int $weekEndsAt = Chronos::SUNDAY;
     205
     206    /**
     207     * Instance of the diff formatting object.
     208     *
     209     * @var \FakerPress\ThirdParty\Cake\Chronos\DifferenceFormatterInterface|null
     210     */
     211    protected static ?DifferenceFormatterInterface $diffFormatter = null;
     212
     213    /**
     214     * Regex for relative period.
     215     *
     216     * @var string
     217     */
     218    // phpcs:disable Generic.Files.LineLength.TooLong
     219    protected static string $relativePattern = '/this|next|last|tomorrow|yesterday|midnight|today|[+-]|first|last|ago/i';
     220
     221    /**
     222     * Errors from last time createFromFormat() was called.
     223     *
     224     * @var array|false
     225     */
     226    protected static array|false $lastErrors = false;
    81227
    82228    /**
     
    86232     * for more on the possibility of this constructor returning a test instance.
    87233     *
    88      * @param \DateTimeInterface|string|int|null $time Fixed or relative time
    89      * @param \DateTimeZone|string|null $tz The timezone for the instance
    90      */
    91     public function __construct($time = 'now', $tz = null)
    92     {
    93         if (is_int($time)) {
    94             parent::__construct('@' . $time);
     234     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate|\FakerPress\ThirdParty\Cake\Chronos\ChronosTime|\DateTimeInterface|string|int|null $time Fixed or relative time
     235     * @param \DateTimeZone|string|null $timezone The timezone for the instance
     236     */
     237    public function __construct(
     238        ChronosDate|ChronosTime|DateTimeInterface|string|int|null $time = 'now',
     239        DateTimeZone|string|null $timezone = null
     240    ) {
     241        if (is_int($time) || (is_string($time) && ctype_digit($time))) {
     242            parent::__construct("@{$time}");
    95243
    96244            return;
    97245        }
    98246
    99         if ($tz !== null) {
    100             $tz = $tz instanceof DateTimeZone ? $tz : new DateTimeZone($tz);
    101         }
    102 
    103         if ($time instanceof \DateTimeInterface) {
     247        if ($timezone !== null) {
     248            $timezone = $timezone instanceof DateTimeZone ? $timezone : new DateTimeZone($timezone);
     249        }
     250
     251        if (is_object($time)) {
     252            if ($time instanceof DateTimeInterface) {
     253                $timezone = $time->getTimezone();
     254            }
    104255            $time = $time->format('Y-m-d H:i:s.u');
    105256        }
    106257
    107         static::$_lastErrors = [];
    108258        $testNow = static::getTestNow();
    109259        if ($testNow === null) {
    110             parent::__construct($time ?? 'now', $tz);
     260            parent::__construct($time ?? 'now', $timezone);
    111261
    112262            return;
     
    114264
    115265        $relative = static::hasRelativeKeywords($time);
    116         if (!empty($time) && $time !== 'now' && !$relative) {
    117             parent::__construct($time, $tz);
     266        if ($time && $time !== 'now' && !$relative) {
     267            parent::__construct($time, $timezone);
    118268
    119269            return;
     
    121271
    122272        $testNow = clone $testNow;
    123         $relativetime = static::isTimeExpression($time);
    124         if (!$relativetime && $tz !== $testNow->getTimezone()) {
    125             $testNow = $testNow->setTimezone($tz ?? date_default_timezone_get());
     273        $relativeTime = self::isTimeExpression($time);
     274        if (!$relativeTime && $timezone !== $testNow->getTimezone()) {
     275            $testNow = $testNow->setTimezone($timezone ?? date_default_timezone_get());
    126276        }
    127277
    128278        if ($relative) {
    129             $testNow = $testNow->modify($time);
    130         }
    131 
    132         $time = $testNow->format('Y-m-d H:i:s.u');
    133         parent::__construct($time, $tz);
    134     }
    135 
    136     /**
    137      * Create a new mutable instance from current immutable instance.
    138      *
    139      * @return \FakerPress\ThirdParty\Cake\Chronos\MutableDateTime
    140      */
    141     public function toMutable(): MutableDateTime
    142     {
    143         trigger_error('2.5 Mutable classes will be removed in 3.0', E_USER_DEPRECATED);
    144 
    145         return MutableDateTime::instance($this);
    146     }
    147 
    148     /**
    149      * Get a copy of the instance
    150      *
    151      * @return static
    152      */
    153     public function copy(): ChronosInterface
    154     {
    155         return clone $this;
    156     }
    157 
    158     /**
    159      * Set a ChronosInterface instance (real or mock) to be returned when a "now"
     279            $testNow = $testNow->modify($time ?? 'now');
     280        }
     281
     282        parent::__construct($testNow->format('Y-m-d H:i:s.u'), $timezone);
     283    }
     284
     285    /**
     286     * Set a Chronos instance (real or mock) to be returned when a "now"
    160287     * instance is created.  The provided instance will be returned
    161288     * specifically under the following conditions:
    162      *   - A call to the static now() method, ex. ChronosInterface::now()
     289     *   - A call to the static now() method, ex. Chronos::now()
    163290     *   - When a null (or blank string) is passed to the constructor or parse(), ex. new Chronos(null)
    164291     *   - When the string "now" is passed to the constructor or parse(), ex. new Chronos('now')
    165      *   - When a string containing the desired time is passed to ChronosInterface::parse()
     292     *   - When a string containing the desired time is passed to Chronos::parse()
    166293     *
    167294     * Note the timezone parameter was left out of the examples above and
     
    171298     * parameter of null.
    172299     *
    173      * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosInterface|string|null $testNow The instance to use for all future instances.
     300     * @param \FakerPress\ThirdParty\Cake\Chronos\Chronos|string|null $testNow The instance to use for all future instances.
    174301     * @return void
    175302     */
    176     public static function setTestNow($testNow = null): void
     303    public static function setTestNow(Chronos|string|null $testNow = null): void
    177304    {
    178305        static::$testNow = is_string($testNow) ? static::parse($testNow) : $testNow;
     
    180307
    181308    /**
    182      * Get the ChronosInterface instance (real or mock) to be returned when a "now"
     309     * Get the Chronos instance (real or mock) to be returned when a "now"
    183310     * instance is created.
    184311     *
    185      * @return \FakerPress\ThirdParty\Cake\Chronos\ChronosInterface|null The current instance used for testing
    186      */
    187     public static function getTestNow(): ?ChronosInterface
     312     * @return \FakerPress\ThirdParty\Cake\Chronos\Chronos|null The current instance used for testing
     313     */
     314    public static function getTestNow(): ?Chronos
    188315    {
    189316        return static::$testNow;
     
    199326    {
    200327        return static::$testNow !== null;
     328    }
     329
     330    /**
     331     * Determine if there is just a time in the time string
     332     *
     333     * @param string|null $time The time string to check.
     334     * @return bool true if there is a keyword, otherwise false
     335     */
     336    private static function isTimeExpression(?string $time): bool
     337    {
     338        // Just a time
     339        if (is_string($time) && preg_match('/^[0-2]?[0-9]:[0-5][0-9](?::[0-5][0-9](?:\.[0-9]{1,6})?)?$/', $time)) {
     340            return true;
     341        }
     342
     343        return false;
     344    }
     345
     346    /**
     347     * Determine if there is a relative keyword in the time string, this is to
     348     * create dates relative to now for test instances. e.g.: next tuesday
     349     *
     350     * @param string|null $time The time string to check.
     351     * @return bool true if there is a keyword, otherwise false
     352     */
     353    public static function hasRelativeKeywords(?string $time): bool
     354    {
     355        if (self::isTimeExpression($time)) {
     356            return true;
     357        }
     358        // skip common format with a '-' in it
     359        if ($time && preg_match('/[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}/', $time) !== 1) {
     360            return preg_match(static::$relativePattern, $time) > 0;
     361        }
     362
     363        return false;
     364    }
     365
     366    /**
     367     * Get weekend days
     368     *
     369     * @return array
     370     */
     371    public static function getWeekendDays(): array
     372    {
     373        return static::$weekendDays;
     374    }
     375
     376    /**
     377     * Set weekend days
     378     *
     379     * @param array $days Which days are 'weekends'.
     380     * @return void
     381     */
     382    public static function setWeekendDays(array $days): void
     383    {
     384        static::$weekendDays = $days;
     385    }
     386
     387    /**
     388     * Get the first day of week
     389     *
     390     * @return int
     391     */
     392    public static function getWeekStartsAt(): int
     393    {
     394        return static::$weekStartsAt;
     395    }
     396
     397    /**
     398     * Set the first day of week
     399     *
     400     * @param int $day The day the week starts with.
     401     * @return void
     402     */
     403    public static function setWeekStartsAt(int $day): void
     404    {
     405        static::$weekStartsAt = $day;
     406    }
     407
     408    /**
     409     * Get the last day of week
     410     *
     411     * @return int
     412     */
     413    public static function getWeekEndsAt(): int
     414    {
     415        return static::$weekEndsAt;
     416    }
     417
     418    /**
     419     * Set the last day of week
     420     *
     421     * @param int $day The day the week ends with.
     422     * @return void
     423     */
     424    public static function setWeekEndsAt(int $day): void
     425    {
     426        static::$weekEndsAt = $day;
     427    }
     428
     429    /**
     430     * Get the difference formatter instance or overwrite the current one.
     431     *
     432     * @param \FakerPress\ThirdParty\Cake\Chronos\DifferenceFormatterInterface|null $formatter The formatter instance when setting.
     433     * @return \FakerPress\ThirdParty\Cake\Chronos\DifferenceFormatterInterface The formatter instance.
     434     */
     435    public static function diffFormatter(?DifferenceFormatterInterface $formatter = null): DifferenceFormatterInterface
     436    {
     437        if ($formatter === null) {
     438            if (static::$diffFormatter === null) {
     439                static::$diffFormatter = new DifferenceFormatter();
     440            }
     441
     442            return static::$diffFormatter;
     443        }
     444
     445        return static::$diffFormatter = $formatter;
     446    }
     447
     448    /**
     449     * Create an instance from a DateTimeInterface
     450     *
     451     * @param \DateTimeInterface $other The datetime instance to convert.
     452     * @return static
     453     */
     454    public static function instance(DateTimeInterface $other): static
     455    {
     456        return new static($other);
     457    }
     458
     459    /**
     460     * Create an instance from a string.  This is an alias for the
     461     * constructor that allows better fluent syntax as it allows you to do
     462     * Chronos::parse('Monday next week')->fn() rather than
     463     * (new Chronos('Monday next week'))->fn()
     464     *
     465     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate|\FakerPress\ThirdParty\Cake\Chronos\ChronosTime|\DateTimeInterface|string|int|null $time The strtotime compatible string to parse
     466     * @param \DateTimeZone|string|null $timezone The DateTimeZone object or timezone name.
     467     * @return static
     468     */
     469    public static function parse(
     470        ChronosDate|ChronosTime|DateTimeInterface|string|int|null $time = 'now',
     471        DateTimeZone|string|null $timezone = null
     472    ): static {
     473        return new static($time, $timezone);
     474    }
     475
     476    /**
     477     * Get an instance for the current date and time
     478     *
     479     * @param \DateTimeZone|string|null $timezone The DateTimeZone object or timezone name.
     480     * @return static
     481     */
     482    public static function now(DateTimeZone|string|null $timezone = null): static
     483    {
     484        return new static('now', $timezone);
     485    }
     486
     487    /**
     488     * Create an instance for today
     489     *
     490     * @param \DateTimeZone|string|null $timezone The timezone to use.
     491     * @return static
     492     */
     493    public static function today(DateTimeZone|string|null $timezone = null): static
     494    {
     495        return new static('midnight', $timezone);
     496    }
     497
     498    /**
     499     * Create an instance for tomorrow
     500     *
     501     * @param \DateTimeZone|string|null $timezone The DateTimeZone object or timezone name the new instance should use.
     502     * @return static
     503     */
     504    public static function tomorrow(DateTimeZone|string|null $timezone = null): static
     505    {
     506        return new static('tomorrow, midnight', $timezone);
     507    }
     508
     509    /**
     510     * Create an instance for yesterday
     511     *
     512     * @param \DateTimeZone|string|null $timezone The DateTimeZone object or timezone name the new instance should use.
     513     * @return static
     514     */
     515    public static function yesterday(DateTimeZone|string|null $timezone = null): static
     516    {
     517        return new static('yesterday, midnight', $timezone);
     518    }
     519
     520    /**
     521     * Create an instance for the greatest supported date.
     522     *
     523     * @return static
     524     */
     525    public static function maxValue(): static
     526    {
     527        return static::createFromTimestamp(PHP_INT_MAX);
     528    }
     529
     530    /**
     531     * Create an instance for the lowest supported date.
     532     *
     533     * @return static
     534     */
     535    public static function minValue(): static
     536    {
     537        $max = PHP_INT_SIZE === 4 ? PHP_INT_MAX : PHP_INT_MAX / 10;
     538
     539        return static::createFromTimestamp(~$max);
     540    }
     541
     542    /**
     543     * Create an instance from a specific date and time.
     544     *
     545     * If any of $year, $month or $day are set to null their now() values
     546     * will be used.
     547     *
     548     * If $hour is null it will be set to its now() value and the default values
     549     * for $minute, $second and $microsecond will be their now() values.
     550     * If $hour is not null then the default values for $minute, $second
     551     * and $microsecond will be 0.
     552     *
     553     * @param int|null $year The year to create an instance with.
     554     * @param int|null $month The month to create an instance with.
     555     * @param int|null $day The day to create an instance with.
     556     * @param int|null $hour The hour to create an instance with.
     557     * @param int|null $minute The minute to create an instance with.
     558     * @param int|null $second The second to create an instance with.
     559     * @param int|null $microsecond The microsecond to create an instance with.
     560     * @param \DateTimeZone|string|null $timezone The DateTimeZone object or timezone name the new instance should use.
     561     * @return static
     562     */
     563    public static function create(
     564        ?int $year = null,
     565        ?int $month = null,
     566        ?int $day = null,
     567        ?int $hour = null,
     568        ?int $minute = null,
     569        ?int $second = null,
     570        ?int $microsecond = null,
     571        DateTimeZone|string|null $timezone = null
     572    ): static {
     573        $now = static::now();
     574        $year = $year ?? (int)$now->format('Y');
     575        $month = $month ?? $now->format('m');
     576        $day = $day ?? $now->format('d');
     577
     578        if ($hour === null) {
     579            $hour = $now->format('H');
     580            $minute = $minute ?? $now->format('i');
     581            $second = $second ?? $now->format('s');
     582            $microsecond = $microsecond ?? $now->format('u');
     583        } else {
     584            $minute = $minute ?? 0;
     585            $second = $second ?? 0;
     586            $microsecond = $microsecond ?? 0;
     587        }
     588
     589        $instance = static::createFromFormat(
     590            'Y-m-d H:i:s.u',
     591            sprintf('%s-%s-%s %s:%02s:%02s.%06s', 0, $month, $day, $hour, $minute, $second, $microsecond),
     592            $timezone
     593        );
     594
     595        return $instance->addYears($year);
     596    }
     597
     598    /**
     599     * Create an instance from just a date. The time portion is set to now.
     600     *
     601     * @param int|null $year The year to create an instance with.
     602     * @param int|null $month The month to create an instance with.
     603     * @param int|null $day The day to create an instance with.
     604     * @param \DateTimeZone|string|null $timezone The DateTimeZone object or timezone name the new instance should use.
     605     * @return static
     606     */
     607    public static function createFromDate(
     608        ?int $year = null,
     609        ?int $month = null,
     610        ?int $day = null,
     611        DateTimeZone|string|null $timezone = null
     612    ): static {
     613        return static::create($year, $month, $day, null, null, null, null, $timezone);
     614    }
     615
     616    /**
     617     * Create an instance from just a time. The date portion is set to today.
     618     *
     619     * @param int|null $hour The hour to create an instance with.
     620     * @param int|null $minute The minute to create an instance with.
     621     * @param int|null $second The second to create an instance with.
     622     * @param int|null $microsecond The microsecond to create an instance with.
     623     * @param \DateTimeZone|string|null $timezone The DateTimeZone object or timezone name the new instance should use.
     624     * @return static
     625     */
     626    public static function createFromTime(
     627        ?int $hour = null,
     628        ?int $minute = null,
     629        ?int $second = null,
     630        ?int $microsecond = null,
     631        DateTimeZone|string|null $timezone = null
     632    ): static {
     633        return static::create(null, null, null, $hour, $minute, $second, $microsecond, $timezone);
     634    }
     635
     636    /**
     637     * Create an instance from a specific format
     638     *
     639     * @param string $format The date() compatible format string.
     640     * @param string $time The formatted date string to interpret.
     641     * @param \DateTimeZone|string|null $timezone The DateTimeZone object or timezone name the new instance should use.
     642     * @return static
     643     * @throws \InvalidArgumentException
     644     */
     645    public static function createFromFormat(
     646        string $format,
     647        string $time,
     648        DateTimeZone|string|null $timezone = null
     649    ): static {
     650        if ($timezone !== null) {
     651            $dateTime = parent::createFromFormat($format, $time, $timezone ? static::safeCreateDateTimeZone($timezone) : null);
     652        } else {
     653            $dateTime = parent::createFromFormat($format, $time);
     654        }
     655
     656        static::$lastErrors = DateTimeImmutable::getLastErrors();
     657        if (!$dateTime) {
     658            $message = static::$lastErrors ? implode(PHP_EOL, static::$lastErrors['errors']) : 'Unknown error';
     659
     660            throw new InvalidArgumentException($message);
     661        }
     662
     663        return $dateTime;
     664    }
     665
     666    /**
     667     * Returns parse warnings and errors from the last ``createFromFormat()``
     668     * call.
     669     *
     670     * Returns the same data as DateTimeImmutable::getLastErrors().
     671     *
     672     * @return array|false
     673     */
     674    public static function getLastErrors(): array|false
     675    {
     676        return static::$lastErrors;
     677    }
     678
     679    /**
     680     * Creates an instance from an array of date and time values.
     681     *
     682     * The 'year', 'month' and 'day' values must all be set for a date. The time
     683     * values all default to 0.
     684     *
     685     * The 'timezone' value can be any format supported by `\DateTimeZone`.
     686     *
     687     * Allowed values:
     688     *  - year
     689     *  - month
     690     *  - day
     691     *  - hour
     692     *  - minute
     693     *  - second
     694     *  - microsecond
     695     *  - meridian ('am' or 'pm')
     696     *  - timezone
     697     *
     698     * @param array<int|string> $values Array of date and time values.
     699     * @return static
     700     */
     701    public static function createFromArray(array $values): static
     702    {
     703        $values += ['hour' => 0, 'minute' => 0, 'second' => 0, 'microsecond' => 0, 'timezone' => null];
     704
     705        $formatted = '';
     706        if (
     707            isset($values['year'], $values['month'], $values['day']) &&
     708            (
     709                is_numeric($values['year']) &&
     710                is_numeric($values['month']) &&
     711                is_numeric($values['day'])
     712            )
     713        ) {
     714            $formatted .= sprintf('%04d-%02d-%02d ', $values['year'], $values['month'], $values['day']);
     715        }
     716
     717        if (isset($values['meridian']) && (int)$values['hour'] === 12) {
     718            $values['hour'] = 0;
     719        }
     720        if (isset($values['meridian'])) {
     721            $values['hour'] = strtolower((string)$values['meridian']) === 'am' ? (int)$values['hour'] : (int)$values['hour'] + 12;
     722        }
     723        $formatted .= sprintf(
     724            '%02d:%02d:%02d.%06d',
     725            $values['hour'],
     726            $values['minute'],
     727            $values['second'],
     728            $values['microsecond']
     729        );
     730
     731        assert(!is_int($values['timezone']), 'Timezone cannot be of type `int`');
     732
     733        return static::parse($formatted, $values['timezone']);
     734    }
     735
     736    /**
     737     * Create an instance from a timestamp
     738     *
     739     * @param float|int $timestamp The timestamp to create an instance from.
     740     * @param \DateTimeZone|string|null $timezone The DateTimeZone object or timezone name the new instance should use.
     741     * @return static
     742     */
     743    public static function createFromTimestamp(float|int $timestamp, DateTimeZone|string|null $timezone = null): static
     744    {
     745        $instance = PHP_VERSION_ID >= 80400 ? parent::createFromTimestamp($timestamp) : new static('@' . $timestamp);
     746
     747        return $timezone ? $instance->setTimezone($timezone) : $instance;
     748    }
     749
     750    /**
     751     * Creates a DateTimeZone from a string or a DateTimeZone
     752     *
     753     * @param \DateTimeZone|string|null $object The value to convert.
     754     * @return \DateTimeZone
     755     * @throws \InvalidArgumentException
     756     */
     757    protected static function safeCreateDateTimeZone(DateTimeZone|string|null $object): DateTimeZone
     758    {
     759        if ($object === null) {
     760            return new DateTimeZone(date_default_timezone_get());
     761        }
     762
     763        if ($object instanceof DateTimeZone) {
     764            return $object;
     765        }
     766
     767        return new DateTimeZone($object);
    201768    }
    202769
     
    222789        ?int $minutes = null,
    223790        ?int $seconds = null,
    224         ?int $microseconds = null
     791        ?int $microseconds = null,
    225792    ): DateInterval {
    226793        $spec = 'P';
    227794
     795        $rollover = static::rolloverTime($microseconds, 1_000_000);
     796        $seconds = $seconds === null ? $rollover : $seconds + (int)$rollover;
     797
     798        $rollover = static::rolloverTime($seconds, 60);
     799        $minutes = $minutes === null ? $rollover : $minutes + (int)$rollover;
     800
     801        $rollover = static::rolloverTime($minutes, 60);
     802        $hours = $hours === null ? $rollover : $hours + (int)$rollover;
     803
     804        $rollover = static::rolloverTime($hours, 24);
     805        $days = $days === null ? $rollover : $days + (int)$rollover;
     806
    228807        if ($years) {
    229808            $spec .= $years . 'Y';
     
    241820        if ($hours || $minutes || $seconds) {
    242821            $spec .= 'T';
     822
    243823            if ($hours) {
    244824                $spec .= $hours . 'H';
     
    266846
    267847    /**
     848     * Updates value to remaininger and returns rollover value for time
     849     * unit or null if no rollover.
     850     *
     851     * @param int|null $value Time unit value
     852     * @param int $max Time unit max value
     853     * @return int|null
     854     */
     855    protected static function rolloverTime(?int &$value, int $max): ?int
     856    {
     857        if ($value === null || $value < $max) {
     858            return null;
     859        }
     860
     861        $rollover = intdiv($value, $max);
     862        $value = $value % $max;
     863
     864        return $rollover;
     865    }
     866
     867    /**
     868     * Sets the date and time.
     869     *
     870     * @param int $year The year to set.
     871     * @param int $month The month to set.
     872     * @param int $day The day to set.
     873     * @param int $hour The hour to set.
     874     * @param int $minute The minute to set.
     875     * @param int $second The second to set.
     876     * @return static
     877     */
     878    public function setDateTime(
     879        int $year,
     880        int $month,
     881        int $day,
     882        int $hour,
     883        int $minute,
     884        int $second = 0
     885    ): static {
     886        return $this->setDate($year, $month, $day)->setTime($hour, $minute, $second);
     887    }
     888
     889    /**
     890     * Sets the date.
     891     *
     892     * @param int $year The year to set.
     893     * @param int $month The month to set.
     894     * @param int $day The day to set.
     895     * @return static
     896     */
     897    public function setDate(int $year, int $month, int $day): static
     898    {
     899        return parent::setDate($year, $month, $day);
     900    }
     901
     902    /**
     903     * Sets the date according to the ISO 8601 standard
     904     *
     905     * @param int $year Year of the date.
     906     * @param int $week Week of the date.
     907     * @param int $dayOfWeek Offset from the first day of the week.
     908     * @return static
     909     */
     910    public function setISODate(int $year, int $week, int $dayOfWeek = 1): static
     911    {
     912        return parent::setISODate($year, $week, $dayOfWeek);
     913    }
     914
     915    /**
     916     * Sets the time.
     917     *
     918     * @param int $hours Hours of the time
     919     * @param int $minutes Minutes of the time
     920     * @param int $seconds Seconds of the time
     921     * @param int $microseconds Microseconds of the time
     922     * @return static
     923     */
     924    public function setTime(int $hours, int $minutes, int $seconds = 0, int $microseconds = 0): static
     925    {
     926        return parent::setTime($hours, $minutes, $seconds, $microseconds);
     927    }
     928
     929    /**
     930     * Creates a new instance with date modified according to DateTimeImmutable::modifier().
     931     *
     932     * @param string $modifier Date modifier
     933     * @return static
     934     * @throws \InvalidArgumentException
     935     * @see https://www.php.net/manual/en/datetimeimmutable.modify.php
     936     */
     937    public function modify(string $modifier): static
     938    {
     939        $new = parent::modify($modifier);
     940        if ($new === false) {
     941            throw new InvalidArgumentException(sprintf('Unable to modify date using `%s`', $modifier));
     942        }
     943
     944        return $new;
     945    }
     946
     947    /**
     948     * Returns the difference between this instance and target.
     949     *
     950     * @param \DateTimeInterface $target Target instance
     951     * @param bool $absolute Whether the interval is forced to be positive
     952     * @return \DateInterval
     953     */
     954    public function diff(DateTimeInterface $target, bool $absolute = false): DateInterval
     955    {
     956        return parent::diff($target, $absolute);
     957    }
     958
     959    /**
     960     * Returns formatted date string according to DateTimeImmutable::format().
     961     *
     962     * @param string $format String format
     963     * @return string
     964     */
     965    public function format(string $format): string
     966    {
     967        return parent::format($format);
     968    }
     969
     970    /**
     971     * Returns the timezone offset.
     972     *
     973     * @return int
     974     */
     975    public function getOffset(): int
     976    {
     977        return parent::getOffset();
     978    }
     979
     980    /**
     981     * Sets the date and time based on a Unix timestamp.
     982     *
     983     * @param int $timestamp Unix timestamp representing the date
     984     * @return static
     985     */
     986    public function setTimestamp(int $timestamp): static
     987    {
     988        return parent::setTimestamp($timestamp);
     989    }
     990
     991    /**
     992     * Gets the Unix timestamp for this instance.
     993     *
     994     * @return int
     995     */
     996    public function getTimestamp(): int
     997    {
     998        return parent::getTimestamp();
     999    }
     1000
     1001    /**
     1002     * Set the instance's timezone from a string or object
     1003     *
     1004     * @param \DateTimeZone|string $value The DateTimeZone object or timezone name to use.
     1005     * @return static
     1006     */
     1007    public function setTimezone(DateTimeZone|string $value): static
     1008    {
     1009        return parent::setTimezone(static::safeCreateDateTimeZone($value));
     1010    }
     1011
     1012    /**
     1013     * Return time zone set for this instance.
     1014     *
     1015     * @return \DateTimeZone
     1016     */
     1017    public function getTimezone(): DateTimeZone
     1018    {
     1019        $tz = parent::getTimezone();
     1020        if ($tz === false) {
     1021            throw new RuntimeException('Time zone could not be retrieved.');
     1022        }
     1023
     1024        return $tz;
     1025    }
     1026
     1027    /**
     1028     * Set the time by time string
     1029     *
     1030     * @param string $time Time as string.
     1031     * @return static
     1032     */
     1033    public function setTimeFromTimeString(string $time): static
     1034    {
     1035        $time = explode(':', $time);
     1036        $hour = $time[0];
     1037        $minute = $time[1] ?? 0;
     1038        $second = $time[2] ?? 0;
     1039
     1040        return $this->setTime((int)$hour, (int)$minute, (int)$second);
     1041    }
     1042
     1043    /**
     1044     * Set the instance's timestamp
     1045     *
     1046     * @param int $value The timestamp value to set.
     1047     * @return static
     1048     */
     1049    public function timestamp(int $value): static
     1050    {
     1051        return $this->setTimestamp($value);
     1052    }
     1053
     1054    /**
     1055     * Set the instance's year
     1056     *
     1057     * @param int $value The year value.
     1058     * @return static
     1059     */
     1060    public function year(int $value): static
     1061    {
     1062        return $this->setDate($value, $this->month, $this->day);
     1063    }
     1064
     1065    /**
     1066     * Set the instance's month
     1067     *
     1068     * @param int $value The month value.
     1069     * @return static
     1070     */
     1071    public function month(int $value): static
     1072    {
     1073        return $this->setDate($this->year, $value, $this->day);
     1074    }
     1075
     1076    /**
     1077     * Set the instance's day
     1078     *
     1079     * @param int $value The day value.
     1080     * @return static
     1081     */
     1082    public function day(int $value): static
     1083    {
     1084        return $this->setDate($this->year, $this->month, $value);
     1085    }
     1086
     1087    /**
     1088     * Set the instance's hour
     1089     *
     1090     * @param int $value The hour value.
     1091     * @return static
     1092     */
     1093    public function hour(int $value): static
     1094    {
     1095        return $this->setTime($value, $this->minute, $this->second);
     1096    }
     1097
     1098    /**
     1099     * Set the instance's minute
     1100     *
     1101     * @param int $value The minute value.
     1102     * @return static
     1103     */
     1104    public function minute(int $value): static
     1105    {
     1106        return $this->setTime($this->hour, $value, $this->second);
     1107    }
     1108
     1109    /**
     1110     * Set the instance's second
     1111     *
     1112     * @param int $value The seconds value.
     1113     * @return static
     1114     */
     1115    public function second(int $value): static
     1116    {
     1117        return $this->setTime($this->hour, $this->minute, $value);
     1118    }
     1119
     1120    /**
     1121     * Set the instance's microsecond
     1122     *
     1123     * @param int $value The microsecond value.
     1124     * @return static
     1125     */
     1126    public function microsecond(int $value): static
     1127    {
     1128        return $this->setTime($this->hour, $this->minute, $this->second, $value);
     1129    }
     1130
     1131    /**
     1132     * Add years to the instance. Positive $value travel forward while
     1133     * negative $value travel into the past.
     1134     *
     1135     * If the new ChronosDate does not exist, the last day of the month is used
     1136     * instead instead of overflowing into the next month.
     1137     *
     1138     * ### Example:
     1139     *
     1140     * ```
     1141     *  (new Chronos('2015-01-03'))->addYears(1); // Results in 2016-01-03
     1142     *
     1143     *  (new Chronos('2012-02-29'))->addYears(1); // Results in 2013-02-28
     1144     * ```
     1145     *
     1146     * @param int $value The number of years to add.
     1147     * @return static
     1148     */
     1149    public function addYears(int $value): static
     1150    {
     1151        $month = $this->month;
     1152        $date = $this->modify($value . ' years');
     1153
     1154        if ($date->month !== $month) {
     1155            return $date->modify('last day of previous month');
     1156        }
     1157
     1158        return $date;
     1159    }
     1160
     1161    /**
     1162     * Remove years from the instance.
     1163     *
     1164     * Has the same behavior as `addYears()`.
     1165     *
     1166     * @param int $value The number of years to remove.
     1167     * @return static
     1168     */
     1169    public function subYears(int $value): static
     1170    {
     1171        return $this->addYears(-$value);
     1172    }
     1173
     1174    /**
     1175     * Add years with overflowing to the instance. Positive $value
     1176     * travels forward while negative $value travels into the past.
     1177     *
     1178     * If the new ChronosDate does not exist, the days overflow into the next month.
     1179     *
     1180     * ### Example:
     1181     *
     1182     * ```
     1183     *  (new Chronos('2012-02-29'))->addYearsWithOverflow(1); // Results in 2013-03-01
     1184     * ```
     1185     *
     1186     * @param int $value The number of years to add.
     1187     * @return static
     1188     */
     1189    public function addYearsWithOverflow(int $value): static
     1190    {
     1191        return $this->modify($value . ' year');
     1192    }
     1193
     1194    /**
     1195     * Remove years with overflow from the instance
     1196     *
     1197     * Has the same behavior as `addYeasrWithOverflow()`.
     1198     *
     1199     * @param int $value The number of years to remove.
     1200     * @return static
     1201     */
     1202    public function subYearsWithOverflow(int $value): static
     1203    {
     1204        return $this->addYearsWithOverflow(-1 * $value);
     1205    }
     1206
     1207    /**
     1208     * Add months to the instance. Positive $value travels forward while
     1209     * negative $value travels into the past.
     1210     *
     1211     * When adding or subtracting months, if the resulting time is a date
     1212     * that does not exist, the result of this operation will always be the
     1213     * last day of the intended month.
     1214     *
     1215     * ### Example:
     1216     *
     1217     * ```
     1218     *  (new Chronos('2015-01-03'))->addMonths(1); // Results in 2015-02-03
     1219     *
     1220     *  (new Chronos('2015-01-31'))->addMonths(1); // Results in 2015-02-28
     1221     * ```
     1222     *
     1223     * @param int $value The number of months to add.
     1224     * @return static
     1225     */
     1226    public function addMonths(int $value): static
     1227    {
     1228        $day = $this->day;
     1229        $date = $this->modify($value . ' months');
     1230
     1231        if ($date->day !== $day) {
     1232            return $date->modify('last day of previous month');
     1233        }
     1234
     1235        return $date;
     1236    }
     1237
     1238    /**
     1239     * Remove months from the instance
     1240     *
     1241     * Has the same behavior as `addMonths()`.
     1242     *
     1243     * @param int $value The number of months to remove.
     1244     * @return static
     1245     */
     1246    public function subMonths(int $value): static
     1247    {
     1248        return $this->addMonths(-$value);
     1249    }
     1250
     1251    /**
     1252     * Add months with overflowing to the instance. Positive $value
     1253     * travels forward while negative $value travels into the past.
     1254     *
     1255     * If the new ChronosDate does not exist, the days overflow into the next month.
     1256     *
     1257     * ### Example:
     1258     *
     1259     * ```
     1260     *  (new Chronos('2012-01-30'))->addMonthsWithOverflow(1); // Results in 2013-03-01
     1261     * ```
     1262     *
     1263     * @param int $value The number of months to add.
     1264     * @return static
     1265     */
     1266    public function addMonthsWithOverflow(int $value): static
     1267    {
     1268        return $this->modify($value . ' months');
     1269    }
     1270
     1271    /**
     1272     * Add months with overflowing to the instance. Positive $value
     1273     * travels forward while negative $value travels into the past.
     1274     *
     1275     * If the new ChronosDate does not exist, the days overflow into the next month.
     1276     *
     1277     * ### Example:
     1278     *
     1279     * ```
     1280     *  (new Chronos('2012-01-30'))->addMonthsWithOverflow(1); // Results in 2013-03-01
     1281     * ```
     1282     *
     1283     * @param int $value The number of months to remove.
     1284     * @return static
     1285     */
     1286    public function subMonthsWithOverflow(int $value): static
     1287    {
     1288        return $this->addMonthsWithOverflow(-1 * $value);
     1289    }
     1290
     1291    /**
     1292     * Add days to the instance. Positive $value travels forward while
     1293     * negative $value travels into the past.
     1294     *
     1295     * @param int $value The number of days to add.
     1296     * @return static
     1297     */
     1298    public function addDays(int $value): static
     1299    {
     1300        return $this->modify("$value days");
     1301    }
     1302
     1303    /**
     1304     * Remove days from the instance
     1305     *
     1306     * @param int $value The number of days to remove.
     1307     * @return static
     1308     */
     1309    public function subDays(int $value): static
     1310    {
     1311        return $this->addDays(-$value);
     1312    }
     1313
     1314    /**
     1315     * Add weekdays to the instance. Positive $value travels forward while
     1316     * negative $value travels into the past.
     1317     *
     1318     * @param int $value The number of weekdays to add.
     1319     * @return static
     1320     */
     1321    public function addWeekdays(int $value): static
     1322    {
     1323        return $this->modify($value . ' weekdays, ' . $this->format('H:i:s'));
     1324    }
     1325
     1326    /**
     1327     * Remove weekdays from the instance
     1328     *
     1329     * @param int $value The number of weekdays to remove.
     1330     * @return static
     1331     */
     1332    public function subWeekdays(int $value): static
     1333    {
     1334        return $this->addWeekdays(-$value);
     1335    }
     1336
     1337    /**
     1338     * Add weeks to the instance. Positive $value travels forward while
     1339     * negative $value travels into the past.
     1340     *
     1341     * @param int $value The number of weeks to add.
     1342     * @return static
     1343     */
     1344    public function addWeeks(int $value): static
     1345    {
     1346        return $this->modify("$value week");
     1347    }
     1348
     1349    /**
     1350     * Remove weeks to the instance
     1351     *
     1352     * @param int $value The number of weeks to remove.
     1353     * @return static
     1354     */
     1355    public function subWeeks(int $value): static
     1356    {
     1357        return $this->addWeeks(-$value);
     1358    }
     1359
     1360    /**
     1361     * Add hours to the instance. Positive $value travels forward while
     1362     * negative $value travels into the past.
     1363     *
     1364     * @param int $value The number of hours to add.
     1365     * @return static
     1366     */
     1367    public function addHours(int $value): static
     1368    {
     1369        return $this->modify("$value hour");
     1370    }
     1371
     1372    /**
     1373     * Remove hours from the instance
     1374     *
     1375     * @param int $value The number of hours to remove.
     1376     * @return static
     1377     */
     1378    public function subHours(int $value): static
     1379    {
     1380        return $this->addHours(-$value);
     1381    }
     1382
     1383    /**
     1384     * Add minutes to the instance. Positive $value travels forward while
     1385     * negative $value travels into the past.
     1386     *
     1387     * @param int $value The number of minutes to add.
     1388     * @return static
     1389     */
     1390    public function addMinutes(int $value): static
     1391    {
     1392        return $this->modify("$value minute");
     1393    }
     1394
     1395    /**
     1396     * Remove minutes from the instance
     1397     *
     1398     * @param int $value The number of minutes to remove.
     1399     * @return static
     1400     */
     1401    public function subMinutes(int $value): static
     1402    {
     1403        return $this->addMinutes(-$value);
     1404    }
     1405
     1406    /**
     1407     * Add seconds to the instance. Positive $value travels forward while
     1408     * negative $value travels into the past.
     1409     *
     1410     * @param int $value The number of seconds to add.
     1411     * @return static
     1412     */
     1413    public function addSeconds(int $value): static
     1414    {
     1415        return $this->modify("$value second");
     1416    }
     1417
     1418    /**
     1419     * Remove seconds from the instance
     1420     *
     1421     * @param int $value The number of seconds to remove.
     1422     * @return static
     1423     */
     1424    public function subSeconds(int $value): static
     1425    {
     1426        return $this->addSeconds(-$value);
     1427    }
     1428
     1429    /**
     1430     * Sets the time to 00:00:00
     1431     *
     1432     * @return static
     1433     */
     1434    public function startOfDay(): static
     1435    {
     1436        return $this->modify('midnight');
     1437    }
     1438
     1439    /**
     1440     * Sets the time to 23:59:59 or 23:59:59.999999
     1441     * if `$microseconds` is true.
     1442     *
     1443     * @param bool $microseconds Whether to set microseconds
     1444     * @return static
     1445     */
     1446    public function endOfDay(bool $microseconds = false): static
     1447    {
     1448        if ($microseconds) {
     1449            return $this->modify('23:59:59.999999');
     1450        }
     1451
     1452        return $this->modify('23:59:59');
     1453    }
     1454
     1455    /**
     1456     * Sets the date to the first day of the month and the time to 00:00:00
     1457     *
     1458     * @return static
     1459     */
     1460    public function startOfMonth(): static
     1461    {
     1462        return $this->modify('first day of this month midnight');
     1463    }
     1464
     1465    /**
     1466     * Sets the date to end of the month and time to 23:59:59
     1467     *
     1468     * @return static
     1469     */
     1470    public function endOfMonth(): static
     1471    {
     1472        return $this->modify('last day of this month, 23:59:59');
     1473    }
     1474
     1475    /**
     1476     * Sets the date to the first day of the year and the time to 00:00:00
     1477     *
     1478     * @return static
     1479     */
     1480    public function startOfYear(): static
     1481    {
     1482        return $this->modify('first day of january midnight');
     1483    }
     1484
     1485    /**
     1486     * Sets the date to end of the year and time to 23:59:59
     1487     *
     1488     * @return static
     1489     */
     1490    public function endOfYear(): static
     1491    {
     1492        return $this->modify('last day of december, 23:59:59');
     1493    }
     1494
     1495    /**
     1496     * Sets the date to the first day of the decade and the time to 00:00:00
     1497     *
     1498     * @return static
     1499     */
     1500    public function startOfDecade(): static
     1501    {
     1502        $year = $this->year - $this->year % Chronos::YEARS_PER_DECADE;
     1503
     1504        return $this->modify("first day of january $year, midnight");
     1505    }
     1506
     1507    /**
     1508     * Sets the date to end of the decade and time to 23:59:59
     1509     *
     1510     * @return static
     1511     */
     1512    public function endOfDecade(): static
     1513    {
     1514        $year = $this->year - $this->year % Chronos::YEARS_PER_DECADE + Chronos::YEARS_PER_DECADE - 1;
     1515
     1516        return $this->modify("last day of december $year, 23:59:59");
     1517    }
     1518
     1519    /**
     1520     * Sets the date to the first day of the century and the time to 00:00:00
     1521     *
     1522     * @return static
     1523     */
     1524    public function startOfCentury(): static
     1525    {
     1526        $year = $this->startOfYear()
     1527            ->year($this->year - 1 - ($this->year - 1) % Chronos::YEARS_PER_CENTURY + 1)
     1528            ->year;
     1529
     1530        return $this->modify("first day of january $year, midnight");
     1531    }
     1532
     1533    /**
     1534     * Sets the date to end of the century and time to 23:59:59
     1535     *
     1536     * @return static
     1537     */
     1538    public function endOfCentury(): static
     1539    {
     1540        $y = $this->year - 1
     1541            - ($this->year - 1)
     1542            % Chronos::YEARS_PER_CENTURY
     1543            + Chronos::YEARS_PER_CENTURY;
     1544
     1545        $year = $this->endOfYear()
     1546            ->year($y)
     1547            ->year;
     1548
     1549        return $this->modify("last day of december $year, 23:59:59");
     1550    }
     1551
     1552    /**
     1553     * Sets the date to the first day of week (defined in $weekStartsAt) and the time to 00:00:00
     1554     *
     1555     * @return static
     1556     */
     1557    public function startOfWeek(): static
     1558    {
     1559        $dateTime = $this;
     1560        if ($dateTime->dayOfWeek !== static::$weekStartsAt) {
     1561            $dateTime = $dateTime->previous(static::$weekStartsAt);
     1562        }
     1563
     1564        return $dateTime->startOfDay();
     1565    }
     1566
     1567    /**
     1568     * Sets the date to end of week (defined in $weekEndsAt) and time to 23:59:59
     1569     *
     1570     * @return static
     1571     */
     1572    public function endOfWeek(): static
     1573    {
     1574        $dateTime = $this;
     1575        if ($dateTime->dayOfWeek !== static::$weekEndsAt) {
     1576            $dateTime = $dateTime->next(static::$weekEndsAt);
     1577        }
     1578
     1579        return $dateTime->endOfDay();
     1580    }
     1581
     1582    /**
     1583     * Modify to the next occurrence of a given day of the week.
     1584     * If no dayOfWeek is provided, modify to the next occurrence
     1585     * of the current day of the week.  Use the supplied consts
     1586     * to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     1587     *
     1588     * @param int|null $dayOfWeek The day of the week to move to.
     1589     * @return static
     1590     */
     1591    public function next(?int $dayOfWeek = null): static
     1592    {
     1593        if ($dayOfWeek === null) {
     1594            $dayOfWeek = $this->dayOfWeek;
     1595        }
     1596
     1597        $day = static::$days[$dayOfWeek];
     1598
     1599        return $this->modify("next $day, midnight");
     1600    }
     1601
     1602    /**
     1603     * Modify to the previous occurrence of a given day of the week.
     1604     * If no dayOfWeek is provided, modify to the previous occurrence
     1605     * of the current day of the week.  Use the supplied consts
     1606     * to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     1607     *
     1608     * @param int|null $dayOfWeek The day of the week to move to.
     1609     * @return static
     1610     */
     1611    public function previous(?int $dayOfWeek = null): static
     1612    {
     1613        if ($dayOfWeek === null) {
     1614            $dayOfWeek = $this->dayOfWeek;
     1615        }
     1616
     1617        $day = static::$days[$dayOfWeek];
     1618
     1619        return $this->modify("last $day, midnight");
     1620    }
     1621
     1622    /**
     1623     * Modify to the first occurrence of a given day of the week
     1624     * in the current month. If no dayOfWeek is provided, modify to the
     1625     * first day of the current month.  Use the supplied consts
     1626     * to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     1627     *
     1628     * @param int|null $dayOfWeek The day of the week to move to.
     1629     * @return static
     1630     */
     1631    public function firstOfMonth(?int $dayOfWeek = null): static
     1632    {
     1633        $day = $dayOfWeek === null ? 'day' : static::$days[$dayOfWeek];
     1634
     1635        return $this->modify("first $day of this month, midnight");
     1636    }
     1637
     1638    /**
     1639     * Modify to the last occurrence of a given day of the week
     1640     * in the current month. If no dayOfWeek is provided, modify to the
     1641     * last day of the current month.  Use the supplied consts
     1642     * to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     1643     *
     1644     * @param int|null $dayOfWeek The day of the week to move to.
     1645     * @return static
     1646     */
     1647    public function lastOfMonth(?int $dayOfWeek = null): static
     1648    {
     1649        $day = $dayOfWeek === null ? 'day' : static::$days[$dayOfWeek];
     1650
     1651        return $this->modify("last $day of this month, midnight");
     1652    }
     1653
     1654    /**
     1655     * Modify to the given occurrence of a given day of the week
     1656     * in the current month. If the calculated occurrence is outside the scope
     1657     * of the current month, then return false and no modifications are made.
     1658     * Use the supplied consts to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     1659     *
     1660     * @param int $nth The offset to use.
     1661     * @param int $dayOfWeek The day of the week to move to.
     1662     * @return static|false
     1663     */
     1664    public function nthOfMonth(int $nth, int $dayOfWeek): static|false
     1665    {
     1666        $dateTime = $this->firstOfMonth();
     1667        $check = $dateTime->format('Y-m');
     1668        $dateTime = $dateTime->modify("+$nth " . static::$days[$dayOfWeek]);
     1669
     1670        return $dateTime->format('Y-m') === $check ? $dateTime : false;
     1671    }
     1672
     1673    /**
     1674     * Modify to the first occurrence of a given day of the week
     1675     * in the current quarter. If no dayOfWeek is provided, modify to the
     1676     * first day of the current quarter.  Use the supplied consts
     1677     * to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     1678     *
     1679     * @param int|null $dayOfWeek The day of the week to move to.
     1680     * @return static
     1681     */
     1682    public function firstOfQuarter(?int $dayOfWeek = null): static
     1683    {
     1684        return $this
     1685            ->day(1)
     1686            ->month($this->quarter * Chronos::MONTHS_PER_QUARTER - 2)
     1687            ->firstOfMonth($dayOfWeek);
     1688    }
     1689
     1690    /**
     1691     * Modify to the last occurrence of a given day of the week
     1692     * in the current quarter. If no dayOfWeek is provided, modify to the
     1693     * last day of the current quarter.  Use the supplied consts
     1694     * to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     1695     *
     1696     * @param int|null $dayOfWeek The day of the week to move to.
     1697     * @return static
     1698     */
     1699    public function lastOfQuarter(?int $dayOfWeek = null): static
     1700    {
     1701        return $this
     1702            ->day(1)
     1703            ->month($this->quarter * Chronos::MONTHS_PER_QUARTER)
     1704            ->lastOfMonth($dayOfWeek);
     1705    }
     1706
     1707    /**
     1708     * Modify to the given occurrence of a given day of the week
     1709     * in the current quarter. If the calculated occurrence is outside the scope
     1710     * of the current quarter, then return false and no modifications are made.
     1711     * Use the supplied consts to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     1712     *
     1713     * @param int $nth The offset to use.
     1714     * @param int $dayOfWeek The day of the week to move to.
     1715     * @return static|false
     1716     */
     1717    public function nthOfQuarter(int $nth, int $dayOfWeek): static|false
     1718    {
     1719        $dateTime = $this->day(1)->month($this->quarter * Chronos::MONTHS_PER_QUARTER);
     1720        $lastMonth = $dateTime->month;
     1721        $year = $dateTime->year;
     1722        $dateTime = $dateTime->firstOfQuarter()->modify("+$nth" . static::$days[$dayOfWeek]);
     1723
     1724        return $lastMonth < $dateTime->month || $year !== $dateTime->year ? false : $dateTime;
     1725    }
     1726
     1727    /**
     1728     * Modify to the first occurrence of a given day of the week
     1729     * in the current year. If no dayOfWeek is provided, modify to the
     1730     * first day of the current year.  Use the supplied consts
     1731     * to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     1732     *
     1733     * @param int|null $dayOfWeek The day of the week to move to.
     1734     * @return static
     1735     */
     1736    public function firstOfYear(?int $dayOfWeek = null): static
     1737    {
     1738        $day = $dayOfWeek === null ? 'day' : static::$days[$dayOfWeek];
     1739
     1740        return $this->modify("first $day of january, midnight");
     1741    }
     1742
     1743    /**
     1744     * Modify to the last occurrence of a given day of the week
     1745     * in the current year. If no dayOfWeek is provided, modify to the
     1746     * last day of the current year.  Use the supplied consts
     1747     * to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     1748     *
     1749     * @param int|null $dayOfWeek The day of the week to move to.
     1750     * @return static
     1751     */
     1752    public function lastOfYear(?int $dayOfWeek = null): static
     1753    {
     1754        $day = $dayOfWeek === null ? 'day' : static::$days[$dayOfWeek];
     1755
     1756        return $this->modify("last $day of december, midnight");
     1757    }
     1758
     1759    /**
     1760     * Modify to the given occurrence of a given day of the week
     1761     * in the current year. If the calculated occurrence is outside the scope
     1762     * of the current year, then return false and no modifications are made.
     1763     * Use the supplied consts to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     1764     *
     1765     * @param int $nth The offset to use.
     1766     * @param int $dayOfWeek The day of the week to move to.
     1767     * @return static|false
     1768     */
     1769    public function nthOfYear(int $nth, int $dayOfWeek): static|false
     1770    {
     1771        $dateTime = $this->firstOfYear()->modify("+$nth " . static::$days[$dayOfWeek]);
     1772
     1773        return $this->year === $dateTime->year ? $dateTime : false;
     1774    }
     1775
     1776    /**
     1777     * Determines if the instance is equal to another
     1778     *
     1779     * @param \DateTimeInterface $other The instance to compare with.
     1780     * @return bool
     1781     */
     1782    public function equals(DateTimeInterface $other): bool
     1783    {
     1784        return $this == $other;
     1785    }
     1786
     1787    /**
     1788     * Determines if the instance is not equal to another
     1789     *
     1790     * @param \DateTimeInterface $other The instance to compare with.
     1791     * @return bool
     1792     */
     1793    public function notEquals(DateTimeInterface $other): bool
     1794    {
     1795        return !$this->equals($other);
     1796    }
     1797
     1798    /**
     1799     * Determines if the instance is greater (after) than another
     1800     *
     1801     * @param \DateTimeInterface $other The instance to compare with.
     1802     * @return bool
     1803     */
     1804    public function greaterThan(DateTimeInterface $other): bool
     1805    {
     1806        return $this > $other;
     1807    }
     1808
     1809    /**
     1810     * Determines if the instance is greater (after) than or equal to another
     1811     *
     1812     * @param \DateTimeInterface $other The instance to compare with.
     1813     * @return bool
     1814     */
     1815    public function greaterThanOrEquals(DateTimeInterface $other): bool
     1816    {
     1817        return $this >= $other;
     1818    }
     1819
     1820    /**
     1821     * Determines if the instance is less (before) than another
     1822     *
     1823     * @param \DateTimeInterface $other The instance to compare with.
     1824     * @return bool
     1825     */
     1826    public function lessThan(DateTimeInterface $other): bool
     1827    {
     1828        return $this < $other;
     1829    }
     1830
     1831    /**
     1832     * Determines if the instance is less (before) or equal to another
     1833     *
     1834     * @param \DateTimeInterface $other The instance to compare with.
     1835     * @return bool
     1836     */
     1837    public function lessThanOrEquals(DateTimeInterface $other): bool
     1838    {
     1839        return $this <= $other;
     1840    }
     1841
     1842    /**
     1843     * Determines if the instance is between two others
     1844     *
     1845     * @param \DateTimeInterface $start Start of target range
     1846     * @param \DateTimeInterface $end End of target range
     1847     * @param bool $equals Whether to include the beginning and end of range
     1848     * @return bool
     1849     */
     1850    public function between(DateTimeInterface $start, DateTimeInterface $end, bool $equals = true): bool
     1851    {
     1852        if ($start > $end) {
     1853            [$start, $end] = [$end, $start];
     1854        }
     1855
     1856        if ($equals) {
     1857            return $this->greaterThanOrEquals($start) && $this->lessThanOrEquals($end);
     1858        }
     1859
     1860        return $this->greaterThan($start) && $this->lessThan($end);
     1861    }
     1862
     1863    /**
     1864     * Get the closest date from the instance.
     1865     *
     1866     * @param \DateTimeInterface $first The instance to compare with.
     1867     * @param \DateTimeInterface $second The instance to compare with.
     1868     * @param \DateTimeInterface ...$others Others instances to compare with.
     1869     * @return static
     1870     */
     1871    public function closest(DateTimeInterface $first, DateTimeInterface $second, DateTimeInterface ...$others): static
     1872    {
     1873        $winner = $first;
     1874        $closestDiffInSeconds = $this->diffInSeconds($first);
     1875        foreach ([$second, ...$others] as $other) {
     1876            $otherDiffInSeconds = $this->diffInSeconds($other);
     1877            if ($otherDiffInSeconds < $closestDiffInSeconds) {
     1878                $winner = $other;
     1879                $closestDiffInSeconds = $otherDiffInSeconds;
     1880            }
     1881        }
     1882
     1883        if ($winner instanceof static) {
     1884            return $winner;
     1885        }
     1886
     1887        return new static($winner);
     1888    }
     1889
     1890    /**
     1891     * Get the farthest date from the instance.
     1892     *
     1893     * @param \DateTimeInterface $first The instance to compare with.
     1894     * @param \DateTimeInterface $second The instance to compare with.
     1895     * @param \DateTimeInterface ...$others Others instances to compare with.
     1896     * @return static
     1897     */
     1898    public function farthest(DateTimeInterface $first, DateTimeInterface $second, DateTimeInterface ...$others): static
     1899    {
     1900        $winner = $first;
     1901        $farthestDiffInSeconds = $this->diffInSeconds($first);
     1902        foreach ([$second, ...$others] as $other) {
     1903            $otherDiffInSeconds = $this->diffInSeconds($other);
     1904            if ($otherDiffInSeconds > $farthestDiffInSeconds) {
     1905                $winner = $other;
     1906                $farthestDiffInSeconds = $otherDiffInSeconds;
     1907            }
     1908        }
     1909
     1910        if ($winner instanceof static) {
     1911            return $winner;
     1912        }
     1913
     1914        return new static($winner);
     1915    }
     1916
     1917    /**
     1918     * Get the minimum instance between a given instance (default now) and the current instance.
     1919     *
     1920     * @param \DateTimeInterface|null $other The instance to compare with.
     1921     * @return static
     1922     */
     1923    public function min(?DateTimeInterface $other = null): static
     1924    {
     1925        $other = $other ?? static::now($this->tz);
     1926        $winner = $this->lessThan($other) ? $this : $other;
     1927        if ($winner instanceof static) {
     1928            return $winner;
     1929        }
     1930
     1931        return new static($winner);
     1932    }
     1933
     1934    /**
     1935     * Get the maximum instance between a given instance (default now) and the current instance.
     1936     *
     1937     * @param \DateTimeInterface|null $other The instance to compare with.
     1938     * @return static
     1939     */
     1940    public function max(?DateTimeInterface $other = null): static
     1941    {
     1942        $other = $other ?? static::now($this->tz);
     1943        $winner = $this->greaterThan($other) ? $this : $other;
     1944        if ($winner instanceof static) {
     1945            return $winner;
     1946        }
     1947
     1948        return new static($winner);
     1949    }
     1950
     1951    /**
     1952     * Modify the current instance to the average of a given instance (default now) and the current instance.
     1953     *
     1954     * @param \DateTimeInterface|null $other The instance to compare with.
     1955     * @return static
     1956     */
     1957    public function average(?DateTimeInterface $other = null): static
     1958    {
     1959        $other ??= static::now($this->tz);
     1960
     1961        return $this->addSeconds((int)($this->diffInSeconds($other, false) / 2));
     1962    }
     1963
     1964    /**
     1965     * Determines if the instance is a weekday
     1966     *
     1967     * @return bool
     1968     */
     1969    public function isWeekday(): bool
     1970    {
     1971        return !$this->isWeekend();
     1972    }
     1973
     1974    /**
     1975     * Determines if the instance is a weekend day
     1976     *
     1977     * @return bool
     1978     */
     1979    public function isWeekend(): bool
     1980    {
     1981        return in_array($this->dayOfWeek, Chronos::getWeekendDays(), true);
     1982    }
     1983
     1984    /**
     1985     * Determines if the instance is yesterday
     1986     *
     1987     * @return bool
     1988     */
     1989    public function isYesterday(): bool
     1990    {
     1991        return $this->toDateString() === static::yesterday($this->tz)->toDateString();
     1992    }
     1993
     1994    /**
     1995     * Determines if the instance is today
     1996     *
     1997     * @return bool
     1998     */
     1999    public function isToday(): bool
     2000    {
     2001        return $this->toDateString() === static::now($this->tz)->toDateString();
     2002    }
     2003
     2004    /**
     2005     * Determines if the instance is tomorrow
     2006     *
     2007     * @return bool
     2008     */
     2009    public function isTomorrow(): bool
     2010    {
     2011        return $this->toDateString() === static::tomorrow($this->tz)->toDateString();
     2012    }
     2013
     2014    /**
     2015     * Determines if the instance is within the next week
     2016     *
     2017     * @return bool
     2018     */
     2019    public function isNextWeek(): bool
     2020    {
     2021        return $this->format('W o') === static::now($this->tz)->addWeeks(1)->format('W o');
     2022    }
     2023
     2024    /**
     2025     * Determines if the instance is within the last week
     2026     *
     2027     * @return bool
     2028     */
     2029    public function isLastWeek(): bool
     2030    {
     2031        return $this->format('W o') === static::now($this->tz)->subWeeks(1)->format('W o');
     2032    }
     2033
     2034    /**
     2035     * Determines if the instance is within the next month
     2036     *
     2037     * @return bool
     2038     */
     2039    public function isNextMonth(): bool
     2040    {
     2041        return $this->format('m Y') === static::now($this->tz)->addMonths(1)->format('m Y');
     2042    }
     2043
     2044    /**
     2045     * Determines if the instance is within the last month
     2046     *
     2047     * @return bool
     2048     */
     2049    public function isLastMonth(): bool
     2050    {
     2051        return $this->format('m Y') === static::now($this->tz)->subMonths(1)->format('m Y');
     2052    }
     2053
     2054    /**
     2055     * Determines if the instance is within the next year
     2056     *
     2057     * @return bool
     2058     */
     2059    public function isNextYear(): bool
     2060    {
     2061        return $this->year === static::now($this->tz)->addYears(1)->year;
     2062    }
     2063
     2064    /**
     2065     * Determines if the instance is within the last year
     2066     *
     2067     * @return bool
     2068     */
     2069    public function isLastYear(): bool
     2070    {
     2071        return $this->year === static::now($this->tz)->subYears(1)->year;
     2072    }
     2073
     2074    /**
     2075     * Determines if the instance is within the first half of year
     2076     *
     2077     * @return bool
     2078     */
     2079    public function isFirstHalf(): bool
     2080    {
     2081        return $this->half === 1;
     2082    }
     2083
     2084    /**
     2085     * Determines if the instance is within the second half of year
     2086     *
     2087     * @return bool
     2088     */
     2089    public function isSecondHalf(): bool
     2090    {
     2091        return $this->half === 2;
     2092    }
     2093
     2094    /**
     2095     * Determines if the instance is in the future, ie. greater (after) than now
     2096     *
     2097     * @return bool
     2098     */
     2099    public function isFuture(): bool
     2100    {
     2101        return $this->greaterThan(static::now($this->tz));
     2102    }
     2103
     2104    /**
     2105     * Determines if the instance is in the past, ie. less (before) than now
     2106     *
     2107     * @return bool
     2108     */
     2109    public function isPast(): bool
     2110    {
     2111        return $this->lessThan(static::now($this->tz));
     2112    }
     2113
     2114    /**
     2115     * Determines if the instance is a leap year
     2116     *
     2117     * @return bool
     2118     */
     2119    public function isLeapYear(): bool
     2120    {
     2121        return $this->format('L') === '1';
     2122    }
     2123
     2124    /**
     2125     * Checks if the passed in date is the same day as the instance current day.
     2126     *
     2127     * @param \DateTimeInterface $other The instance to check against.
     2128     * @return bool
     2129     */
     2130    public function isSameDay(DateTimeInterface $other): bool
     2131    {
     2132        if (!$other instanceof static) {
     2133            $other = new static($other);
     2134        }
     2135
     2136        return $this->toDateString() === $other->toDateString();
     2137    }
     2138
     2139    /**
     2140     * Returns whether the passed in date is the same month and year.
     2141     *
     2142     * @param \DateTimeInterface $other The instance to check against.
     2143     * @return bool
     2144     */
     2145    public function isSameMonth(DateTimeInterface $other): bool
     2146    {
     2147        return $this->format('Y-m') === $other->format('Y-m');
     2148    }
     2149
     2150    /**
     2151     * Returns whether passed in date is the same year.
     2152     *
     2153     * @param \DateTimeInterface $other The instance to check against.
     2154     * @return bool
     2155     */
     2156    public function isSameYear(DateTimeInterface $other): bool
     2157    {
     2158        return $this->format('Y') === $other->format('Y');
     2159    }
     2160
     2161    /**
     2162     * Checks if this day is a Sunday.
     2163     *
     2164     * @return bool
     2165     */
     2166    public function isSunday(): bool
     2167    {
     2168        return $this->dayOfWeek === Chronos::SUNDAY;
     2169    }
     2170
     2171    /**
     2172     * Checks if this day is a Monday.
     2173     *
     2174     * @return bool
     2175     */
     2176    public function isMonday(): bool
     2177    {
     2178        return $this->dayOfWeek === Chronos::MONDAY;
     2179    }
     2180
     2181    /**
     2182     * Checks if this day is a Tuesday.
     2183     *
     2184     * @return bool
     2185     */
     2186    public function isTuesday(): bool
     2187    {
     2188        return $this->dayOfWeek === Chronos::TUESDAY;
     2189    }
     2190
     2191    /**
     2192     * Checks if this day is a Wednesday.
     2193     *
     2194     * @return bool
     2195     */
     2196    public function isWednesday(): bool
     2197    {
     2198        return $this->dayOfWeek === Chronos::WEDNESDAY;
     2199    }
     2200
     2201    /**
     2202     * Checks if this day is a Thursday.
     2203     *
     2204     * @return bool
     2205     */
     2206    public function isThursday(): bool
     2207    {
     2208        return $this->dayOfWeek === Chronos::THURSDAY;
     2209    }
     2210
     2211    /**
     2212     * Checks if this day is a Friday.
     2213     *
     2214     * @return bool
     2215     */
     2216    public function isFriday(): bool
     2217    {
     2218        return $this->dayOfWeek === Chronos::FRIDAY;
     2219    }
     2220
     2221    /**
     2222     * Checks if this day is a Saturday.
     2223     *
     2224     * @return bool
     2225     */
     2226    public function isSaturday(): bool
     2227    {
     2228        return $this->dayOfWeek === Chronos::SATURDAY;
     2229    }
     2230
     2231    /**
     2232     * Returns true if this object represents a date within the current week
     2233     *
     2234     * @return bool
     2235     */
     2236    public function isThisWeek(): bool
     2237    {
     2238        return static::now($this->getTimezone())->format('W o') === $this->format('W o');
     2239    }
     2240
     2241    /**
     2242     * Returns true if this object represents a date within the current month
     2243     *
     2244     * @return bool
     2245     */
     2246    public function isThisMonth(): bool
     2247    {
     2248        return static::now($this->getTimezone())->format('m Y') === $this->format('m Y');
     2249    }
     2250
     2251    /**
     2252     * Returns true if this object represents a date within the current year
     2253     *
     2254     * @return bool
     2255     */
     2256    public function isThisYear(): bool
     2257    {
     2258        return static::now($this->getTimezone())->format('Y') === $this->format('Y');
     2259    }
     2260
     2261    /**
     2262     * Check if its the birthday. Compares the date/month values of the two dates.
     2263     *
     2264     * @param \DateTimeInterface|null $other The instance to compare with or null to use current day.
     2265     * @return bool
     2266     */
     2267    public function isBirthday(?DateTimeInterface $other = null): bool
     2268    {
     2269        $other ??= static::now($this->tz);
     2270
     2271        return $this->format('md') === $other->format('md');
     2272    }
     2273
     2274    /**
     2275     * Returns true this instance happened within the specified interval
     2276     *
     2277     * @param string|int $timeInterval the numeric value with space then time type.
     2278     *    Example of valid types: 6 hours, 2 days, 1 minute.
     2279     * @return bool
     2280     */
     2281    public function wasWithinLast(string|int $timeInterval): bool
     2282    {
     2283        $now = new static();
     2284        $interval = $now->modify('-' . $timeInterval);
     2285        $thisTime = $this->format('U');
     2286
     2287        return $thisTime >= $interval->format('U') && $thisTime <= $now->format('U');
     2288    }
     2289
     2290    /**
     2291     * Returns true this instance will happen within the specified interval
     2292     *
     2293     * @param string|int $timeInterval the numeric value with space then time type.
     2294     *    Example of valid types: 6 hours, 2 days, 1 minute.
     2295     * @return bool
     2296     */
     2297    public function isWithinNext(string|int $timeInterval): bool
     2298    {
     2299        $now = new static();
     2300        $interval = $now->modify('+' . $timeInterval);
     2301        $thisTime = $this->format('U');
     2302
     2303        return $thisTime <= $interval->format('U') && $thisTime >= $now->format('U');
     2304    }
     2305
     2306    /**
     2307     * Get the difference by the given interval using a filter callable
     2308     *
     2309     * @param \DateInterval $interval An interval to traverse by
     2310     * @param callable $callback The callback to use for filtering.
     2311     * @param \DateTimeInterface|null $other The instance to difference from.
     2312     * @param bool $absolute Get the absolute of the difference
     2313     * @param int $options DatePeriod options, {@see https://www.php.net/manual/en/class.dateperiod.php}
     2314     * @return int
     2315     */
     2316    public function diffFiltered(
     2317        DateInterval $interval,
     2318        callable $callback,
     2319        ?DateTimeInterface $other = null,
     2320        bool $absolute = true,
     2321        int $options = 0
     2322    ): int {
     2323        $start = $this;
     2324        $end = $other ?? static::now($this->tz);
     2325        $inverse = false;
     2326
     2327        if ($end < $start) {
     2328            $start = $end;
     2329            $end = $this;
     2330            $inverse = true;
     2331        }
     2332
     2333        $period = new DatePeriod($start, $interval, $end, $options);
     2334        $vals = array_filter(iterator_to_array($period), function (DateTimeInterface $date) use ($callback) {
     2335            return $callback(static::instance($date));
     2336        });
     2337
     2338        $diff = count($vals);
     2339
     2340        return $inverse && !$absolute ? -$diff : $diff;
     2341    }
     2342
     2343    /**
     2344     * Get the difference in years
     2345     *
     2346     * @param \DateTimeInterface|null $other The instance to difference from.
     2347     * @param bool $absolute Get the absolute of the difference
     2348     * @return int
     2349     */
     2350    public function diffInYears(?DateTimeInterface $other = null, bool $absolute = true): int
     2351    {
     2352        $diff = $this->diff($other ?? static::now($this->tz), $absolute);
     2353
     2354        return $diff->invert ? -$diff->y : $diff->y;
     2355    }
     2356
     2357    /**
     2358     * Get the difference in months
     2359     *
     2360     * @param \DateTimeInterface|null $other The instance to difference from.
     2361     * @param bool $absolute Get the absolute of the difference
     2362     * @return int
     2363     */
     2364    public function diffInMonths(?DateTimeInterface $other = null, bool $absolute = true): int
     2365    {
     2366        $diff = $this->diff($other ?? static::now($this->tz), $absolute);
     2367        $months = $diff->y * Chronos::MONTHS_PER_YEAR + $diff->m;
     2368
     2369        return $diff->invert ? -$months : $months;
     2370    }
     2371
     2372    /**
     2373     * Get the difference in months ignoring the timezone. This means the months are calculated
     2374     * in the specified timezone without converting to UTC first. This prevents the day from changing
     2375     * which can change the month.
     2376     *
     2377     * For example, if comparing `2019-06-01 Asia/Tokyo` and `2019-10-01 Asia/Tokyo`,
     2378     * the result would be 4 months instead of 3 when using normal `DateTime::diff()`.
     2379     *
     2380     * @param \DateTimeInterface|null $other The instance to difference from.
     2381     * @param bool $absolute Get the absolute of the difference
     2382     * @return int
     2383     */
     2384    public function diffInMonthsIgnoreTimezone(?DateTimeInterface $other = null, bool $absolute = true): int
     2385    {
     2386        $utcTz = new DateTimeZone('UTC');
     2387        $source = new static($this->format('Y-m-d H:i:s.u'), $utcTz);
     2388
     2389        $other ??= static::now($this->tz);
     2390        $other = new static($other->format('Y-m-d H:i:s.u'), $utcTz);
     2391
     2392        return $source->diffInMonths($other, $absolute);
     2393    }
     2394
     2395    /**
     2396     * Get the difference in weeks
     2397     *
     2398     * @param \DateTimeInterface|null $other The instance to difference from.
     2399     * @param bool $absolute Get the absolute of the difference
     2400     * @return int
     2401     */
     2402    public function diffInWeeks(?DateTimeInterface $other = null, bool $absolute = true): int
     2403    {
     2404        return (int)($this->diffInDays($other, $absolute) / Chronos::DAYS_PER_WEEK);
     2405    }
     2406
     2407    /**
     2408     * Get the difference in days
     2409     *
     2410     * @param \DateTimeInterface|null $other The instance to difference from.
     2411     * @param bool $absolute Get the absolute of the difference
     2412     * @return int
     2413     */
     2414    public function diffInDays(?DateTimeInterface $other = null, bool $absolute = true): int
     2415    {
     2416        $diff = $this->diff($other ?? static::now($this->tz), $absolute);
     2417
     2418        return $diff->invert ? -(int)$diff->days : (int)$diff->days;
     2419    }
     2420
     2421    /**
     2422     * Get the difference in days using a filter callable
     2423     *
     2424     * @param callable $callback The callback to use for filtering.
     2425     * @param \DateTimeInterface|null $other The instance to difference from.
     2426     * @param bool $absolute Get the absolute of the difference
     2427     * @param int $options DatePeriod options, {@see https://www.php.net/manual/en/class.dateperiod.php}
     2428     * @return int
     2429     */
     2430    public function diffInDaysFiltered(
     2431        callable $callback,
     2432        ?DateTimeInterface $other = null,
     2433        bool $absolute = true,
     2434        int $options = 0
     2435    ): int {
     2436        return $this->diffFiltered(new DateInterval('P1D'), $callback, $other, $absolute, $options);
     2437    }
     2438
     2439    /**
     2440     * Get the difference in hours using a filter callable
     2441     *
     2442     * @param callable $callback The callback to use for filtering.
     2443     * @param \DateTimeInterface|null $other The instance to difference from.
     2444     * @param bool $absolute Get the absolute of the difference
     2445     * @param int $options DatePeriod options, {@see https://www.php.net/manual/en/class.dateperiod.php}
     2446     * @return int
     2447     */
     2448    public function diffInHoursFiltered(
     2449        callable $callback,
     2450        ?DateTimeInterface $other = null,
     2451        bool $absolute = true,
     2452        int $options = 0
     2453    ): int {
     2454        return $this->diffFiltered(new DateInterval('PT1H'), $callback, $other, $absolute, $options);
     2455    }
     2456
     2457    /**
     2458     * Get the difference in weekdays
     2459     *
     2460     * @param \DateTimeInterface|null $other The instance to difference from.
     2461     * @param bool $absolute Get the absolute of the difference
     2462     * @param int $options DatePeriod options, {@see https://www.php.net/manual/en/class.dateperiod.php}
     2463     * @return int
     2464     */
     2465    public function diffInWeekdays(?DateTimeInterface $other = null, bool $absolute = true, int $options = 0): int
     2466    {
     2467        return $this->diffInDaysFiltered(function (Chronos $date) {
     2468            return $date->isWeekday();
     2469        }, $other, $absolute, $options);
     2470    }
     2471
     2472    /**
     2473     * Get the difference in weekend days using a filter
     2474     *
     2475     * @param \DateTimeInterface|null $other The instance to difference from.
     2476     * @param bool $absolute Get the absolute of the difference
     2477     * @param int $options DatePeriod options, {@see https://www.php.net/manual/en/class.dateperiod.php}
     2478     * @return int
     2479     */
     2480    public function diffInWeekendDays(?DateTimeInterface $other = null, bool $absolute = true, int $options = 0): int
     2481    {
     2482        return $this->diffInDaysFiltered(function (Chronos $date) {
     2483            return $date->isWeekend();
     2484        }, $other, $absolute, $options);
     2485    }
     2486
     2487    /**
     2488     * Get the difference in hours
     2489     *
     2490     * @param \DateTimeInterface|null $other The instance to difference from.
     2491     * @param bool $absolute Get the absolute of the difference
     2492     * @return int
     2493     */
     2494    public function diffInHours(?DateTimeInterface $other = null, bool $absolute = true): int
     2495    {
     2496        return (int)(
     2497            $this->diffInSeconds($other, $absolute)
     2498            / Chronos::SECONDS_PER_MINUTE
     2499            / Chronos::MINUTES_PER_HOUR
     2500        );
     2501    }
     2502
     2503    /**
     2504     * Get the difference in minutes
     2505     *
     2506     * @param \DateTimeInterface|null $other The instance to difference from.
     2507     * @param bool $absolute Get the absolute of the difference
     2508     * @return int
     2509     */
     2510    public function diffInMinutes(?DateTimeInterface $other = null, bool $absolute = true): int
     2511    {
     2512        return (int)($this->diffInSeconds($other, $absolute) / Chronos::SECONDS_PER_MINUTE);
     2513    }
     2514
     2515    /**
     2516     * Get the difference in seconds
     2517     *
     2518     * @param \DateTimeInterface|null $other The instance to difference from.
     2519     * @param bool $absolute Get the absolute of the difference
     2520     * @return int
     2521     */
     2522    public function diffInSeconds(?DateTimeInterface $other = null, bool $absolute = true): int
     2523    {
     2524        $other ??= static::now($this->tz);
     2525        $value = $other->getTimestamp() - $this->getTimestamp();
     2526
     2527        return $absolute ? abs($value) : $value;
     2528    }
     2529
     2530    /**
     2531     * The number of seconds since midnight.
     2532     *
     2533     * @return int
     2534     */
     2535    public function secondsSinceMidnight(): int
     2536    {
     2537        return $this->diffInSeconds($this->startOfDay());
     2538    }
     2539
     2540    /**
     2541     * The number of seconds until 23:59:59.
     2542     *
     2543     * @return int
     2544     */
     2545    public function secondsUntilEndOfDay(): int
     2546    {
     2547        return $this->diffInSeconds($this->endOfDay());
     2548    }
     2549
     2550    /**
     2551     * Convenience method for getting the remaining time from a given time.
     2552     *
     2553     * @param \DateTimeInterface $other The date to get the remaining time from.
     2554     * @return \DateInterval|bool The DateInterval object representing the difference between the two dates or FALSE on failure.
     2555     */
     2556    public static function fromNow(DateTimeInterface $other): DateInterval|bool
     2557    {
     2558        $timeNow = new static();
     2559
     2560        return $timeNow->diff($other);
     2561    }
     2562
     2563    /**
     2564     * Get the difference in a human readable format.
     2565     *
     2566     * When comparing a value in the past to default now:
     2567     * 1 hour ago
     2568     * 5 months ago
     2569     *
     2570     * When comparing a value in the future to default now:
     2571     * 1 hour from now
     2572     * 5 months from now
     2573     *
     2574     * When comparing a value in the past to another value:
     2575     * 1 hour before
     2576     * 5 months before
     2577     *
     2578     * When comparing a value in the future to another value:
     2579     * 1 hour after
     2580     * 5 months after
     2581     *
     2582     * @param \DateTimeInterface|null $other The datetime to compare with.
     2583     * @param bool $absolute removes time difference modifiers ago, after, etc
     2584     * @return string
     2585     */
     2586    public function diffForHumans(?DateTimeInterface $other = null, bool $absolute = false): string
     2587    {
     2588        return static::diffFormatter()->diffForHumans($this, $other, $absolute);
     2589    }
     2590
     2591    /**
     2592     * Returns a DateTimeImmutable instance
     2593     *
     2594     * This method returns a PHP DateTimeImmutable without Chronos extensions.
     2595     *
     2596     * @return \DateTimeImmutable
     2597     */
     2598    public function toNative(): DateTimeImmutable
     2599    {
     2600        return new DateTimeImmutable($this->format('Y-m-d H:i:s.u'), $this->getTimezone());
     2601    }
     2602
     2603    /**
     2604     * Get a part of the object
     2605     *
     2606     * @param string $name The property name to read.
     2607     * @return \DateTimeZone|string|float|int|bool The property value.
     2608     * @throws \InvalidArgumentException
     2609     */
     2610    public function __get(string $name): string|float|int|bool|DateTimeZone
     2611    {
     2612        static $formats = [
     2613            'year' => 'Y',
     2614            'yearIso' => 'o',
     2615            'month' => 'n',
     2616            'day' => 'j',
     2617            'hour' => 'G',
     2618            'minute' => 'i',
     2619            'second' => 's',
     2620            'micro' => 'u',
     2621            'microsecond' => 'u',
     2622            'dayOfWeek' => 'N',
     2623            'dayOfYear' => 'z',
     2624            'weekOfYear' => 'W',
     2625            'daysInMonth' => 't',
     2626            'timestamp' => 'U',
     2627        ];
     2628
     2629        switch (true) {
     2630            case isset($formats[$name]):
     2631                return (int)$this->format($formats[$name]);
     2632
     2633            case $name === 'dayOfWeekName':
     2634                return $this->format('l');
     2635
     2636            case $name === 'weekOfMonth':
     2637                return (int)ceil($this->day / Chronos::DAYS_PER_WEEK);
     2638
     2639            case $name === 'age':
     2640                return $this->diffInYears();
     2641
     2642            case $name === 'quarter':
     2643                return (int)ceil($this->month / 3);
     2644
     2645            case $name === 'half':
     2646                return $this->month <= 6 ? 1 : 2;
     2647
     2648            case $name === 'offset':
     2649                return $this->getOffset();
     2650
     2651            case $name === 'offsetHours':
     2652                return $this->getOffset() / Chronos::SECONDS_PER_MINUTE / Chronos::MINUTES_PER_HOUR;
     2653
     2654            case $name === 'dst':
     2655                return $this->format('I') === '1';
     2656
     2657            case $name === 'local':
     2658                return $this->offset === $this->setTimezone(date_default_timezone_get())->offset;
     2659
     2660            case $name === 'utc':
     2661                return $this->offset === 0;
     2662
     2663            case $name === 'timezone' || $name === 'tz':
     2664                return $this->getTimezone();
     2665
     2666            case $name === 'timezoneName' || $name === 'tzName':
     2667                return $this->getTimezone()->getName();
     2668
     2669            default:
     2670                throw new InvalidArgumentException(sprintf('Unknown getter `%s`', $name));
     2671        }
     2672    }
     2673
     2674    /**
     2675     * Check if an attribute exists on the object
     2676     *
     2677     * @param string $name The property name to check.
     2678     * @return bool Whether the property exists.
     2679     */
     2680    public function __isset(string $name): bool
     2681    {
     2682        try {
     2683            $this->__get($name);
     2684        } catch (InvalidArgumentException $e) {
     2685            return false;
     2686        }
     2687
     2688        return true;
     2689    }
     2690
     2691    /**
    2682692     * Return properties for debugging.
    2692693     *
     
    2722696    public function __debugInfo(): array
    2732697    {
     2698        /** @var \DateTimeZone $timezone */
     2699        $timezone = $this->getTimezone();
     2700
    2742701        $properties = [
    2752702            'hasFixedNow' => static::hasTestNow(),
    2762703            'time' => $this->format('Y-m-d H:i:s.u'),
    277             'timezone' => $this->getTimezone()->getName(),
     2704            'timezone' => $timezone->getName(),
    2782705        ];
    2792706
    2802707        return $properties;
    2812708    }
    282 
    283     /**
    284      * Deprecation helper to compare types
    285      *
    286      * Future versions of Chronos will not support comparing date/datetimes to each other.
    287      *
    288      * @param object $first The first object.
    289      * @param object|null $second The second object
    290      * @return void
    291      * @internal
    292      */
    293     public static function checkTypes(object $first, $second): void
    294     {
    295         $firstClass = get_class($first);
    296         $secondClass = $second !== null ? get_class($second) : null;
    297         if ($second !== null && $firstClass !== $secondClass) {
    298             trigger_error(
    299                 "2.5 Comparing {$firstClass} and {$secondClass} is deprecated. " .
    300                 'In 3.0 this functionality will be removed.',
    301                 E_USER_DEPRECATED
    302             );
    303         }
    304     }
    3052709}
  • fakerpress/tags/0.8.0/vendor-prefixed/cakephp/chronos/src/ChronosDate.php

    r3296016 r3297704  
    33
    44/**
    5  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
     5 * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
    66 *
    77 * Licensed under The MIT License
    88 * Redistributions of files must retain the above copyright notice.
    99 *
    10  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
    11  * @link          http://cakephp.org CakePHP(tm) Project
    12  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
     10 * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
     11 * @link          https://cakephp.org CakePHP(tm) Project
     12 * @license       https://www.opensource.org/licenses/mit-license.php MIT License
    1313 */
    1414
    1515namespace FakerPress\ThirdParty\Cake\Chronos;
    1616
     17use DateInterval;
     18use DatePeriod;
    1719use DateTimeImmutable;
     20use DateTimeInterface;
    1821use DateTimeZone;
    1922use InvalidArgumentException;
     23use Stringable;
    2024
    2125/**
    22  * An immutable date object that converts all time components into 00:00:00.
     26 * An immutable date object.
    2327 *
    2428 * This class is useful when you want to represent a calendar date and ignore times.
     
    2832 * @property-read int $year
    2933 * @property-read int $yearIso
    30  * @property-read int $month
    31  * @property-read int $day
    32  * @property-read int $hour
    33  * @property-read int $minute
    34  * @property-read int $second
    35  * @property-read int $micro
    36  * @property-read int $microsecond
    37  * @property-read int $timestamp seconds since the Unix Epoch
    38  * @property-read \DateTimeZone $timezone the current timezone
    39  * @property-read \DateTimeZone $tz alias of timezone
    40  * @property-read int $dayOfWeek 1 (for Monday) through 7 (for Sunday)
    41  * @property-read int $dayOfYear 0 through 365
    42  * @property-read int $weekOfMonth 1 through 5
    43  * @property-read int $weekOfYear ISO-8601 week number of year, weeks starting on Monday
    44  * @property-read int $daysInMonth number of days in the given month
     34 * @property-read int<1, 12> $month
     35 * @property-read int<1, 31> $day
     36 * @property-read int<1, 7> $dayOfWeek 1 (for Monday) through 7 (for Sunday)
     37 * @property-read int<0, 365> $dayOfYear 0 through 365
     38 * @property-read int<1, 5> $weekOfMonth 1 through 5
     39 * @property-read int<1, 53> $weekOfYear ISO-8601 week number of year, weeks starting on Monday
     40 * @property-read int<1, 31> $daysInMonth number of days in the given month
    4541 * @property-read int $age does a diffInYears() with default parameters
    46  * @property-read int $quarter the quarter of this instance, 1 - 4
    47  * @property-read int $offset the timezone offset in seconds from UTC
    48  * @property-read int $offsetHours the timezone offset in hours from UTC
    49  * @property-read bool $dst daylight savings time indicator, true if DST, false otherwise
    50  * @property-read bool $local checks if the timezone is local, true if local, false otherwise
    51  * @property-read bool $utc checks if the timezone is UTC, true if UTC, false otherwise
    52  * @property-read string $timezoneName
    53  * @property-read string $tzName
     42 * @property-read int<1, 4> $quarter the quarter of this instance, 1 - 4
     43 * @property-read int<1, 2> $half the half of the year, with 1 for months Jan...Jun and 2 for Jul...Dec.
     44 * @psalm-immutable
     45 * @psalm-consistent-constructor
    5446 */
    55 class ChronosDate extends DateTimeImmutable implements ChronosInterface
     47class ChronosDate implements Stringable
    5648{
    57     use Traits\ComparisonTrait;
    58     use Traits\DifferenceTrait;
    59     use Traits\FactoryTrait;
    60     use Traits\FormattingTrait;
    61     use Traits\FrozenTimeTrait;
    62     use Traits\MagicPropertyTrait;
    63     use Traits\ModifierTrait;
    64     use Traits\TestingAidTrait;
     49    use FormattingTrait;
     50
     51    /**
     52     * Default format to use for __toString method when type juggling occurs.
     53     *
     54     * @var string
     55     */
     56    public const DEFAULT_TO_STRING_FORMAT = 'Y-m-d';
    6557
    6658    /**
     
    6961     * @var string
    7062     */
    71     protected static $toStringFormat = 'Y-m-d';
     63    protected static string $toStringFormat = self::DEFAULT_TO_STRING_FORMAT;
     64
     65    /**
     66     * Names of days of the week.
     67     *
     68     * @var array
     69     */
     70    protected static array $days = [
     71        Chronos::MONDAY => 'Monday',
     72        Chronos::TUESDAY => 'Tuesday',
     73        Chronos::WEDNESDAY => 'Wednesday',
     74        Chronos::THURSDAY => 'Thursday',
     75        Chronos::FRIDAY => 'Friday',
     76        Chronos::SATURDAY => 'Saturday',
     77        Chronos::SUNDAY => 'Sunday',
     78    ];
     79
     80    /**
     81     * Instance of the diff formatting object.
     82     *
     83     * @var \FakerPress\ThirdParty\Cake\Chronos\DifferenceFormatterInterface|null
     84     */
     85    protected static ?DifferenceFormatterInterface $diffFormatter = null;
     86
     87    /**
     88     * Errors from last time createFromFormat() was called.
     89     *
     90     * @var array|false
     91     */
     92    protected static array|false $lastErrors = false;
     93
     94    /**
     95     * @var \DateTimeImmutable
     96     */
     97    protected DateTimeImmutable $native;
    7298
    7399    /**
    74100     * Create a new Immutable Date instance.
    75101     *
    76      * You can specify the timezone for the $time parameter. This timezone will
    77      * not be used in any future modifications to the Date instance.
    78      *
    79      * The $timezone parameter is ignored if $time is a DateTimeInterface
    80      * instance.
    81      *
    82      * Please see the testing aids section (specifically static::setTestNow())
    83      * for more on the possibility of this constructor returning a test instance.
    84      *
    85      * Date instances lack time components, however due to limitations in PHP's
    86      * internal Datetime object the time will always be set to 00:00:00, and the
    87      * timezone will always be the server local time. Normalizing the timezone allows for
    88      * subtraction/addition to have deterministic results.
    89      *
    90      * @param \DateTimeInterface|string|int|null $time Fixed or relative time
    91      * @param \DateTimeZone|string|null $tz The timezone in which the date is taken
    92      */
    93     public function __construct($time = 'now', $tz = null)
    94     {
    95         if ($tz !== null) {
    96             $tz = $tz instanceof DateTimeZone ? $tz : new DateTimeZone($tz);
    97         }
     102     * Dates do not have time or timezone components exposed. Internally
     103     * ChronosDate wraps a PHP DateTimeImmutable but limits modifications
     104     * to only those that operate on day values.
     105     *
     106     * By default dates will be calculated from the server's default timezone.
     107     * You can use the `timezone` parameter to use a different timezone. Timezones
     108     * are used when parsing relative date expressions like `today` and `yesterday`
     109     * but do not participate in parsing values like `2022-01-01`.
     110     *
     111     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate|\DateTimeInterface|string $time Fixed or relative time
     112     * @param \DateTimeZone|string|null $timezone The time zone used for 'now'
     113     */
     114    public function __construct(
     115        ChronosDate|DateTimeInterface|string $time = 'now',
     116        DateTimeZone|string|null $timezone = null
     117    ) {
     118        $this->native = $this->createNative($time, $timezone);
     119    }
     120
     121    /**
     122     * Initializes the PHP DateTimeImmutable object.
     123     *
     124     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate|\DateTimeInterface|string $time Fixed or relative time
     125     * @param \DateTimeZone|string|null $timezone The time zone used for 'now'
     126     * @return \DateTimeImmutable
     127     */
     128    protected function createNative(
     129        ChronosDate|DateTimeInterface|string $time,
     130        DateTimeZone|string|null $timezone
     131    ): DateTimeImmutable {
     132        if (!is_string($time)) {
     133            return new DateTimeImmutable($time->format('Y-m-d 00:00:00'));
     134        }
     135
     136        $timezone ??= date_default_timezone_get();
     137        $timezone = $timezone instanceof DateTimeZone ? $timezone : new DateTimeZone($timezone);
    98138
    99139        $testNow = Chronos::getTestNow();
    100         if ($testNow === null || !static::isRelativeOnly($time)) {
    101             $time = $this->stripTime($time, $tz);
    102             parent::__construct($time);
    103 
    104             return;
    105         }
    106 
    107         $testNow = clone $testNow;
    108         if ($tz !== null && $tz !== $testNow->getTimezone()) {
    109             $testNow = $testNow->setTimezone($tz ?? date_default_timezone_get());
    110         }
    111         if (!empty($time)) {
     140        if ($testNow === null) {
     141            $time = new DateTimeImmutable($time, $timezone);
     142
     143            return new DateTimeImmutable($time->format('Y-m-d 00:00:00'));
     144        }
     145
     146        $testNow = $testNow->setTimezone($timezone);
     147        if ($time !== 'now') {
    112148            $testNow = $testNow->modify($time);
    113149        }
    114150
    115         $time = $testNow->format('Y-m-d 00:00:00');
    116         parent::__construct($time);
    117     }
    118 
    119     /**
    120      * Create a new mutable instance from current immutable instance.
    121      *
    122      * @return \FakerPress\ThirdParty\Cake\Chronos\MutableDate
    123      */
    124     public function toMutable(): MutableDate
    125     {
    126         trigger_error('2.5 Mutable classes will be removed in 3.0', E_USER_DEPRECATED);
    127 
    128         return MutableDate::instance($this);
     151        return new DateTimeImmutable($testNow->format('Y-m-d 00:00:00'));
     152    }
     153
     154    /**
     155     * Get today's date.
     156     *
     157     * @param \DateTimeZone|string|null $timezone Time zone to use for now.
     158     * @return static
     159     */
     160    public static function now(DateTimeZone|string|null $timezone = null): static
     161    {
     162        return new static('now', $timezone);
     163    }
     164
     165    /**
     166     * Get today's date.
     167     *
     168     * @param \DateTimeZone|string|null $timezone Time zone to use for today.
     169     * @return static
     170     */
     171    public static function today(DateTimeZone|string|null $timezone = null): static
     172    {
     173        return static::now($timezone);
     174    }
     175
     176    /**
     177     * Get tomorrow's date.
     178     *
     179     * @param \DateTimeZone|string|null $timezone Time zone to use for tomorrow.
     180     * @return static
     181     */
     182    public static function tomorrow(DateTimeZone|string|null $timezone = null): static
     183    {
     184        return new static('tomorrow', $timezone);
     185    }
     186
     187    /**
     188     * Get yesterday's date.
     189     *
     190     * @param \DateTimeZone|string|null $timezone Time zone to use for yesterday.
     191     * @return static
     192     */
     193    public static function yesterday(DateTimeZone|string|null $timezone = null): static
     194    {
     195        return new static('yesterday', $timezone);
     196    }
     197
     198    /**
     199     * Create an instance from a string.  This is an alias for the
     200     * constructor that allows better fluent syntax as it allows you to do
     201     * Chronos::parse('Monday next week')->fn() rather than
     202     * (new Chronos('Monday next week'))->fn()
     203     *
     204     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate|\DateTimeInterface|string $time The strtotime compatible string to parse
     205     * @return static
     206     */
     207    public static function parse(ChronosDate|DateTimeInterface|string $time): static
     208    {
     209        return new static($time);
     210    }
     211
     212    /**
     213     * Create an instance from a specific date.
     214     *
     215     * @param int $year The year to create an instance with.
     216     * @param int $month The month to create an instance with.
     217     * @param int $day The day to create an instance with.
     218     * @return static
     219     */
     220    public static function create(int $year, int $month, int $day): static
     221    {
     222        $instance = static::createFromFormat(
     223            'Y-m-d',
     224            sprintf('%s-%s-%s', 0, $month, $day),
     225        );
     226
     227        return $instance->addYears($year);
     228    }
     229
     230    /**
     231     * Create an instance from a specific format
     232     *
     233     * @param string $format The date() compatible format string.
     234     * @param string $time The formatted date string to interpret.
     235     * @return static
     236     * @throws \InvalidArgumentException
     237     */
     238    public static function createFromFormat(
     239        string $format,
     240        string $time,
     241    ): static {
     242        $dateTime = DateTimeImmutable::createFromFormat($format, $time);
     243
     244        static::$lastErrors = DateTimeImmutable::getLastErrors();
     245        if (!$dateTime) {
     246            $message = static::$lastErrors ? implode(PHP_EOL, static::$lastErrors['errors']) : 'Unknown error';
     247
     248            throw new InvalidArgumentException($message);
     249        }
     250
     251        return new static($dateTime);
     252    }
     253
     254    /**
     255     * Returns parse warnings and errors from the last ``createFromFormat()``
     256     * call.
     257     *
     258     * Returns the same data as DateTimeImmutable::getLastErrors().
     259     *
     260     * @return array|false
     261     */
     262    public static function getLastErrors(): array|false
     263    {
     264        return static::$lastErrors;
     265    }
     266
     267    /**
     268     * Creates an instance from an array of date values.
     269     *
     270     * Allowed values:
     271     *  - year
     272     *  - month
     273     *  - day
     274     *
     275     * @param array<int|string> $values Array of date and time values.
     276     * @return static
     277     */
     278    public static function createFromArray(array $values): static
     279    {
     280        $formatted = sprintf('%04d-%02d-%02d ', $values['year'], $values['month'], $values['day']);
     281
     282        return static::parse($formatted);
     283    }
     284
     285    /**
     286     * Get the difference formatter instance or overwrite the current one.
     287     *
     288     * @param \FakerPress\ThirdParty\Cake\Chronos\DifferenceFormatterInterface|null $formatter The formatter instance when setting.
     289     * @return \FakerPress\ThirdParty\Cake\Chronos\DifferenceFormatterInterface The formatter instance.
     290     */
     291    public static function diffFormatter(?DifferenceFormatterInterface $formatter = null): DifferenceFormatterInterface
     292    {
     293        if ($formatter === null) {
     294            if (static::$diffFormatter === null) {
     295                static::$diffFormatter = new DifferenceFormatter();
     296            }
     297
     298            return static::$diffFormatter;
     299        }
     300
     301        return static::$diffFormatter = $formatter;
     302    }
     303
     304    /**
     305     * Add an Interval to a Date
     306     *
     307     * Any changes to the time will be ignored and reset to 00:00:00
     308     *
     309     * @param \DateInterval $interval The interval to modify this date by.
     310     * @return static A modified Date instance
     311     */
     312    public function add(DateInterval $interval): static
     313    {
     314        if ($interval->f > 0 || $interval->s > 0 || $interval->i > 0 || $interval->h > 0) {
     315            throw new InvalidArgumentException('Cannot add intervals with time components');
     316        }
     317        $new = clone $this;
     318        $new->native = $new->native->add($interval)->setTime(0, 0, 0);
     319
     320        return $new;
     321    }
     322
     323    /**
     324     * Subtract an Interval from a Date.
     325     *
     326     * Any changes to the time will be ignored and reset to 00:00:00
     327     *
     328     * @param \DateInterval $interval The interval to modify this date by.
     329     * @return static A modified Date instance
     330     */
     331    public function sub(DateInterval $interval): static
     332    {
     333        if ($interval->f > 0 || $interval->s > 0 || $interval->i > 0 || $interval->h > 0) {
     334            throw new InvalidArgumentException('Cannot subtract intervals with time components');
     335        }
     336        $new = clone $this;
     337        $new->native = $new->native->sub($interval)->setTime(0, 0, 0);
     338
     339        return $new;
     340    }
     341
     342    /**
     343     * Creates a new instance with date modified according to DateTimeImmutable::modifier().
     344     *
     345     * Attempting to change a time component will raise an exception
     346     *
     347     * @param string $modifier Date modifier
     348     * @return static
     349     */
     350    public function modify(string $modifier): static
     351    {
     352        if (preg_match('/hour|minute|second/', $modifier)) {
     353            throw new InvalidArgumentException('Cannot modify date objects by time values');
     354        }
     355
     356        $new = clone $this;
     357        $new->native = $new->native->modify($modifier);
     358        if ($new->native === false) {
     359            throw new InvalidArgumentException(sprintf('Unable to modify date using `%s`', $modifier));
     360        }
     361
     362        if ($new->format('H:i:s') !== '00:00:00') {
     363            $new->native = $new->native->setTime(0, 0, 0);
     364        }
     365
     366        return $new;
     367    }
     368
     369    /**
     370     * Sets the date.
     371     *
     372     * @param int $year The year to set.
     373     * @param int $month The month to set.
     374     * @param int $day The day to set.
     375     * @return static
     376     */
     377    public function setDate(int $year, int $month, int $day): static
     378    {
     379        $new = clone $this;
     380        $new->native = $new->native->setDate($year, $month, $day);
     381
     382        return $new;
     383    }
     384
     385    /**
     386     * Sets the date according to the ISO 8601 standard
     387     *
     388     * @param int $year Year of the date.
     389     * @param int $week Week of the date.
     390     * @param int $dayOfWeek Offset from the first day of the week.
     391     * @return static
     392     */
     393    public function setISODate(int $year, int $week, int $dayOfWeek = 1): static
     394    {
     395        $new = clone $this;
     396        $new->native = $new->native->setISODate($year, $week, $dayOfWeek);
     397
     398        return $new;
     399    }
     400
     401    /**
     402     * Returns the difference between this instance and target.
     403     *
     404     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate $target Target instance
     405     * @param bool $absolute Whether the interval is forced to be positive
     406     * @return \DateInterval
     407     */
     408    public function diff(ChronosDate $target, bool $absolute = false): DateInterval
     409    {
     410        return $this->native->diff($target->native, $absolute);
     411    }
     412
     413    /**
     414     * Returns formatted date string according to DateTimeImmutable::format().
     415     *
     416     * @param string $format String format
     417     * @return string
     418     */
     419    public function format(string $format): string
     420    {
     421        return $this->native->format($format);
     422    }
     423
     424    /**
     425     * Set the instance's year
     426     *
     427     * @param int $value The year value.
     428     * @return static
     429     */
     430    public function year(int $value): static
     431    {
     432        return $this->setDate($value, $this->month, $this->day);
     433    }
     434
     435    /**
     436     * Set the instance's month
     437     *
     438     * @param int $value The month value.
     439     * @return static
     440     */
     441    public function month(int $value): static
     442    {
     443        return $this->setDate($this->year, $value, $this->day);
     444    }
     445
     446    /**
     447     * Set the instance's day
     448     *
     449     * @param int $value The day value.
     450     * @return static
     451     */
     452    public function day(int $value): static
     453    {
     454        return $this->setDate($this->year, $this->month, $value);
     455    }
     456
     457    /**
     458     * Add years to the instance. Positive $value travel forward while
     459     * negative $value travel into the past.
     460     *
     461     * If the new ChronosDate does not exist, the last day of the month is used
     462     * instead instead of overflowing into the next month.
     463     *
     464     * ### Example:
     465     *
     466     * ```
     467     *  (new Chronos('2015-01-03'))->addYears(1); // Results in 2016-01-03
     468     *
     469     *  (new Chronos('2012-02-29'))->addYears(1); // Results in 2013-02-28
     470     * ```
     471     *
     472     * @param int $value The number of years to add.
     473     * @return static
     474     */
     475    public function addYears(int $value): static
     476    {
     477        $month = $this->month;
     478        $date = $this->modify($value . ' years');
     479
     480        if ($date->month !== $month) {
     481            return $date->modify('last day of previous month');
     482        }
     483
     484        return $date;
     485    }
     486
     487    /**
     488     * Remove years from the instance.
     489     *
     490     * Has the same behavior as `addYears()`.
     491     *
     492     * @param int $value The number of years to remove.
     493     * @return static
     494     */
     495    public function subYears(int $value): static
     496    {
     497        return $this->addYears(-$value);
     498    }
     499
     500    /**
     501     * Add years with overflowing to the instance. Positive $value
     502     * travels forward while negative $value travels into the past.
     503     *
     504     * If the new ChronosDate does not exist, the days overflow into the next month.
     505     *
     506     * ### Example:
     507     *
     508     * ```
     509     *  (new Chronos('2012-02-29'))->addYearsWithOverflow(1); // Results in 2013-03-01
     510     * ```
     511     *
     512     * @param int $value The number of years to add.
     513     * @return static
     514     */
     515    public function addYearsWithOverflow(int $value): static
     516    {
     517        return $this->modify($value . ' year');
     518    }
     519
     520    /**
     521     * Remove years with overflow from the instance
     522     *
     523     * Has the same behavior as `addYeasrWithOverflow()`.
     524     *
     525     * @param int $value The number of years to remove.
     526     * @return static
     527     */
     528    public function subYearsWithOverflow(int $value): static
     529    {
     530        return $this->addYearsWithOverflow(-1 * $value);
     531    }
     532
     533    /**
     534     * Add months to the instance. Positive $value travels forward while
     535     * negative $value travels into the past.
     536     *
     537     * When adding or subtracting months, if the resulting time is a date
     538     * that does not exist, the result of this operation will always be the
     539     * last day of the intended month.
     540     *
     541     * ### Example:
     542     *
     543     * ```
     544     *  (new Chronos('2015-01-03'))->addMonths(1); // Results in 2015-02-03
     545     *
     546     *  (new Chronos('2015-01-31'))->addMonths(1); // Results in 2015-02-28
     547     * ```
     548     *
     549     * @param int $value The number of months to add.
     550     * @return static
     551     */
     552    public function addMonths(int $value): static
     553    {
     554        $day = $this->day;
     555        $date = $this->modify($value . ' months');
     556
     557        if ($date->day !== $day) {
     558            return $date->modify('last day of previous month');
     559        }
     560
     561        return $date;
     562    }
     563
     564    /**
     565     * Remove months from the instance
     566     *
     567     * Has the same behavior as `addMonths()`.
     568     *
     569     * @param int $value The number of months to remove.
     570     * @return static
     571     */
     572    public function subMonths(int $value): static
     573    {
     574        return $this->addMonths(-$value);
     575    }
     576
     577    /**
     578     * Add months with overflowing to the instance. Positive $value
     579     * travels forward while negative $value travels into the past.
     580     *
     581     * If the new ChronosDate does not exist, the days overflow into the next month.
     582     *
     583     * ### Example:
     584     *
     585     * ```
     586     *  (new Chronos('2012-01-30'))->addMonthsWithOverflow(1); // Results in 2013-03-01
     587     * ```
     588     *
     589     * @param int $value The number of months to add.
     590     * @return static
     591     */
     592    public function addMonthsWithOverflow(int $value): static
     593    {
     594        return $this->modify($value . ' months');
     595    }
     596
     597    /**
     598     * Add months with overflowing to the instance. Positive $value
     599     * travels forward while negative $value travels into the past.
     600     *
     601     * If the new ChronosDate does not exist, the days overflow into the next month.
     602     *
     603     * ### Example:
     604     *
     605     * ```
     606     *  (new Chronos('2012-01-30'))->addMonthsWithOverflow(1); // Results in 2013-03-01
     607     * ```
     608     *
     609     * @param int $value The number of months to remove.
     610     * @return static
     611     */
     612    public function subMonthsWithOverflow(int $value): static
     613    {
     614        return $this->addMonthsWithOverflow(-1 * $value);
     615    }
     616
     617    /**
     618     * Add days to the instance. Positive $value travels forward while
     619     * negative $value travels into the past.
     620     *
     621     * @param int $value The number of days to add.
     622     * @return static
     623     */
     624    public function addDays(int $value): static
     625    {
     626        return $this->modify("$value days");
     627    }
     628
     629    /**
     630     * Remove days from the instance
     631     *
     632     * @param int $value The number of days to remove.
     633     * @return static
     634     */
     635    public function subDays(int $value): static
     636    {
     637        return $this->addDays(-$value);
     638    }
     639
     640    /**
     641     * Add weekdays to the instance. Positive $value travels forward while
     642     * negative $value travels into the past.
     643     *
     644     * @param int $value The number of weekdays to add.
     645     * @return static
     646     */
     647    public function addWeekdays(int $value): static
     648    {
     649        return $this->modify($value . ' weekdays, ' . $this->format('H:i:s'));
     650    }
     651
     652    /**
     653     * Remove weekdays from the instance
     654     *
     655     * @param int $value The number of weekdays to remove.
     656     * @return static
     657     */
     658    public function subWeekdays(int $value): static
     659    {
     660        return $this->addWeekdays(-$value);
     661    }
     662
     663    /**
     664     * Add weeks to the instance. Positive $value travels forward while
     665     * negative $value travels into the past.
     666     *
     667     * @param int $value The number of weeks to add.
     668     * @return static
     669     */
     670    public function addWeeks(int $value): static
     671    {
     672        return $this->modify("$value week");
     673    }
     674
     675    /**
     676     * Remove weeks to the instance
     677     *
     678     * @param int $value The number of weeks to remove.
     679     * @return static
     680     */
     681    public function subWeeks(int $value): static
     682    {
     683        return $this->addWeeks(-$value);
     684    }
     685
     686    /**
     687     * Resets the date to the first day of the month
     688     *
     689     * @return static
     690     */
     691    public function startOfMonth(): static
     692    {
     693        return $this->modify('first day of this month');
     694    }
     695
     696    /**
     697     * Resets the date to end of the month
     698     *
     699     * @return static
     700     */
     701    public function endOfMonth(): static
     702    {
     703        return $this->modify('last day of this month');
     704    }
     705
     706    /**
     707     * Resets the date to the first day of the year
     708     *
     709     * @return static
     710     */
     711    public function startOfYear(): static
     712    {
     713        return $this->modify('first day of january');
     714    }
     715
     716    /**
     717     * Resets the date to end of the year
     718     *
     719     * @return static
     720     */
     721    public function endOfYear(): static
     722    {
     723        return $this->modify('last day of december');
     724    }
     725
     726    /**
     727     * Resets the date to the first day of the decade
     728     *
     729     * @return static
     730     */
     731    public function startOfDecade(): static
     732    {
     733        $year = $this->year - $this->year % Chronos::YEARS_PER_DECADE;
     734
     735        return $this->modify("first day of january $year");
     736    }
     737
     738    /**
     739     * Resets the date to end of the decade
     740     *
     741     * @return static
     742     */
     743    public function endOfDecade(): static
     744    {
     745        $year = $this->year - $this->year % Chronos::YEARS_PER_DECADE + Chronos::YEARS_PER_DECADE - 1;
     746
     747        return $this->modify("last day of december $year");
     748    }
     749
     750    /**
     751     * Resets the date to the first day of the century
     752     *
     753     * @return static
     754     */
     755    public function startOfCentury(): static
     756    {
     757        $year = $this->startOfYear()
     758            ->year($this->year - 1 - ($this->year - 1) % Chronos::YEARS_PER_CENTURY + 1)
     759            ->year;
     760
     761        return $this->modify("first day of january $year");
     762    }
     763
     764    /**
     765     * Resets the date to end of the century and time to 23:59:59
     766     *
     767     * @return static
     768     */
     769    public function endOfCentury(): static
     770    {
     771        $y = $this->year - 1
     772            - ($this->year - 1)
     773            % Chronos::YEARS_PER_CENTURY
     774            + Chronos::YEARS_PER_CENTURY;
     775
     776        $year = $this->endOfYear()
     777            ->year($y)
     778            ->year;
     779
     780        return $this->modify("last day of december $year");
     781    }
     782
     783    /**
     784     * Resets the date to the first day of week (defined in $weekStartsAt)
     785     *
     786     * @return static
     787     */
     788    public function startOfWeek(): static
     789    {
     790        $dateTime = $this;
     791        if ($dateTime->dayOfWeek !== Chronos::getWeekStartsAt()) {
     792            $dateTime = $dateTime->previous(Chronos::getWeekStartsAt());
     793        }
     794
     795        return $dateTime;
     796    }
     797
     798    /**
     799     * Resets the date to end of week (defined in $weekEndsAt) and time to 23:59:59
     800     *
     801     * @return static
     802     */
     803    public function endOfWeek(): static
     804    {
     805        $dateTime = $this;
     806        if ($dateTime->dayOfWeek !== Chronos::getWeekEndsAt()) {
     807            $dateTime = $dateTime->next(Chronos::getWeekEndsAt());
     808        }
     809
     810        return $dateTime;
     811    }
     812
     813    /**
     814     * Modify to the next occurrence of a given day of the week.
     815     * If no dayOfWeek is provided, modify to the next occurrence
     816     * of the current day of the week.  Use the supplied consts
     817     * to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     818     *
     819     * @param int|null $dayOfWeek The day of the week to move to.
     820     * @return static
     821     */
     822    public function next(?int $dayOfWeek = null): static
     823    {
     824        if ($dayOfWeek === null) {
     825            $dayOfWeek = $this->dayOfWeek;
     826        }
     827
     828        $day = static::$days[$dayOfWeek];
     829
     830        return $this->modify("next $day");
     831    }
     832
     833    /**
     834     * Modify to the previous occurrence of a given day of the week.
     835     * If no dayOfWeek is provided, modify to the previous occurrence
     836     * of the current day of the week.  Use the supplied consts
     837     * to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     838     *
     839     * @param int|null $dayOfWeek The day of the week to move to.
     840     * @return static
     841     */
     842    public function previous(?int $dayOfWeek = null): static
     843    {
     844        if ($dayOfWeek === null) {
     845            $dayOfWeek = $this->dayOfWeek;
     846        }
     847
     848        $day = static::$days[$dayOfWeek];
     849
     850        return $this->modify("last $day");
     851    }
     852
     853    /**
     854     * Modify to the first occurrence of a given day of the week
     855     * in the current month. If no dayOfWeek is provided, modify to the
     856     * first day of the current month.  Use the supplied consts
     857     * to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     858     *
     859     * @param int|null $dayOfWeek The day of the week to move to.
     860     * @return static
     861     */
     862    public function firstOfMonth(?int $dayOfWeek = null): static
     863    {
     864        $day = $dayOfWeek === null ? 'day' : static::$days[$dayOfWeek];
     865
     866        return $this->modify("first $day of this month");
     867    }
     868
     869    /**
     870     * Modify to the last occurrence of a given day of the week
     871     * in the current month. If no dayOfWeek is provided, modify to the
     872     * last day of the current month.  Use the supplied consts
     873     * to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     874     *
     875     * @param int|null $dayOfWeek The day of the week to move to.
     876     * @return static
     877     */
     878    public function lastOfMonth(?int $dayOfWeek = null): static
     879    {
     880        $day = $dayOfWeek === null ? 'day' : static::$days[$dayOfWeek];
     881
     882        return $this->modify("last $day of this month");
     883    }
     884
     885    /**
     886     * Modify to the given occurrence of a given day of the week
     887     * in the current month. If the calculated occurrence is outside the scope
     888     * of the current month, then return false and no modifications are made.
     889     * Use the supplied consts to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     890     *
     891     * @param int $nth The offset to use.
     892     * @param int $dayOfWeek The day of the week to move to.
     893     * @return static|false
     894     */
     895    public function nthOfMonth(int $nth, int $dayOfWeek): static|false
     896    {
     897        $dateTime = $this->firstOfMonth();
     898        $check = $dateTime->format('Y-m');
     899        $dateTime = $dateTime->modify("+$nth " . static::$days[$dayOfWeek]);
     900
     901        return $dateTime->format('Y-m') === $check ? $dateTime : false;
     902    }
     903
     904    /**
     905     * Modify to the first occurrence of a given day of the week
     906     * in the current quarter. If no dayOfWeek is provided, modify to the
     907     * first day of the current quarter.  Use the supplied consts
     908     * to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     909     *
     910     * @param int|null $dayOfWeek The day of the week to move to.
     911     * @return static
     912     */
     913    public function firstOfQuarter(?int $dayOfWeek = null): static
     914    {
     915        return $this
     916            ->day(1)
     917            ->month($this->quarter * Chronos::MONTHS_PER_QUARTER - 2)
     918            ->firstOfMonth($dayOfWeek);
     919    }
     920
     921    /**
     922     * Modify to the last occurrence of a given day of the week
     923     * in the current quarter. If no dayOfWeek is provided, modify to the
     924     * last day of the current quarter.  Use the supplied consts
     925     * to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     926     *
     927     * @param int|null $dayOfWeek The day of the week to move to.
     928     * @return static
     929     */
     930    public function lastOfQuarter(?int $dayOfWeek = null): static
     931    {
     932        return $this
     933            ->day(1)
     934            ->month($this->quarter * Chronos::MONTHS_PER_QUARTER)
     935            ->lastOfMonth($dayOfWeek);
     936    }
     937
     938    /**
     939     * Modify to the given occurrence of a given day of the week
     940     * in the current quarter. If the calculated occurrence is outside the scope
     941     * of the current quarter, then return false and no modifications are made.
     942     * Use the supplied consts to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     943     *
     944     * @param int $nth The offset to use.
     945     * @param int $dayOfWeek The day of the week to move to.
     946     * @return static|false
     947     */
     948    public function nthOfQuarter(int $nth, int $dayOfWeek): static|false
     949    {
     950        $dateTime = $this->day(1)->month($this->quarter * Chronos::MONTHS_PER_QUARTER);
     951        $lastMonth = $dateTime->month;
     952        $year = $dateTime->year;
     953        $dateTime = $dateTime->firstOfQuarter()->modify("+$nth" . static::$days[$dayOfWeek]);
     954
     955        return $lastMonth < $dateTime->month || $year !== $dateTime->year ? false : $dateTime;
     956    }
     957
     958    /**
     959     * Modify to the first occurrence of a given day of the week
     960     * in the current year. If no dayOfWeek is provided, modify to the
     961     * first day of the current year.  Use the supplied consts
     962     * to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     963     *
     964     * @param int|null $dayOfWeek The day of the week to move to.
     965     * @return static
     966     */
     967    public function firstOfYear(?int $dayOfWeek = null): static
     968    {
     969        $day = $dayOfWeek === null ? 'day' : static::$days[$dayOfWeek];
     970
     971        return $this->modify("first $day of january");
     972    }
     973
     974    /**
     975     * Modify to the last occurrence of a given day of the week
     976     * in the current year. If no dayOfWeek is provided, modify to the
     977     * last day of the current year.  Use the supplied consts
     978     * to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     979     *
     980     * @param int|null $dayOfWeek The day of the week to move to.
     981     * @return static
     982     */
     983    public function lastOfYear(?int $dayOfWeek = null): static
     984    {
     985        $day = $dayOfWeek === null ? 'day' : static::$days[$dayOfWeek];
     986
     987        return $this->modify("last $day of december");
     988    }
     989
     990    /**
     991     * Modify to the given occurrence of a given day of the week
     992     * in the current year. If the calculated occurrence is outside the scope
     993     * of the current year, then return false and no modifications are made.
     994     * Use the supplied consts to indicate the desired dayOfWeek, ex. Chronos::MONDAY.
     995     *
     996     * @param int $nth The offset to use.
     997     * @param int $dayOfWeek The day of the week to move to.
     998     * @return static|false
     999     */
     1000    public function nthOfYear(int $nth, int $dayOfWeek): static|false
     1001    {
     1002        $dateTime = $this->firstOfYear()->modify("+$nth " . static::$days[$dayOfWeek]);
     1003
     1004        return $this->year === $dateTime->year ? $dateTime : false;
     1005    }
     1006
     1007    /**
     1008     * Determines if the instance is equal to another
     1009     *
     1010     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate $other The instance to compare with.
     1011     * @return bool
     1012     */
     1013    public function equals(ChronosDate $other): bool
     1014    {
     1015        return $this->native == $other->native;
     1016    }
     1017
     1018    /**
     1019     * Determines if the instance is not equal to another
     1020     *
     1021     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate $other The instance to compare with.
     1022     * @return bool
     1023     */
     1024    public function notEquals(ChronosDate $other): bool
     1025    {
     1026        return !$this->equals($other);
     1027    }
     1028
     1029    /**
     1030     * Determines if the instance is greater (after) than another
     1031     *
     1032     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate $other The instance to compare with.
     1033     * @return bool
     1034     */
     1035    public function greaterThan(ChronosDate $other): bool
     1036    {
     1037        return $this->native > $other->native;
     1038    }
     1039
     1040    /**
     1041     * Determines if the instance is greater (after) than or equal to another
     1042     *
     1043     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate $other The instance to compare with.
     1044     * @return bool
     1045     */
     1046    public function greaterThanOrEquals(ChronosDate $other): bool
     1047    {
     1048        return $this->native >= $other->native;
     1049    }
     1050
     1051    /**
     1052     * Determines if the instance is less (before) than another
     1053     *
     1054     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate $other The instance to compare with.
     1055     * @return bool
     1056     */
     1057    public function lessThan(ChronosDate $other): bool
     1058    {
     1059        return $this->native < $other->native;
     1060    }
     1061
     1062    /**
     1063     * Determines if the instance is less (before) or equal to another
     1064     *
     1065     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate $other The instance to compare with.
     1066     * @return bool
     1067     */
     1068    public function lessThanOrEquals(ChronosDate $other): bool
     1069    {
     1070        return $this->native <= $other->native;
     1071    }
     1072
     1073    /**
     1074     * Determines if the instance is between two others
     1075     *
     1076     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate $start Start of target range
     1077     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate $end End of target range
     1078     * @param bool $equals Whether to include the beginning and end of range
     1079     * @return bool
     1080     */
     1081    public function between(ChronosDate $start, ChronosDate $end, bool $equals = true): bool
     1082    {
     1083        if ($start->greaterThan($end)) {
     1084            [$start, $end] = [$end, $start];
     1085        }
     1086
     1087        if ($equals) {
     1088            return $this->greaterThanOrEquals($start) && $this->lessThanOrEquals($end);
     1089        }
     1090
     1091        return $this->greaterThan($start) && $this->lessThan($end);
     1092    }
     1093
     1094    /**
     1095     * Get the closest date from the instance.
     1096     *
     1097     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate $first The instance to compare with.
     1098     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate $second The instance to compare with.
     1099     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate ...$others Others instance to compare with.
     1100     * @return self
     1101     */
     1102    public function closest(ChronosDate $first, ChronosDate $second, ChronosDate ...$others): ChronosDate
     1103    {
     1104        $closest = $first;
     1105        $closestDiffInDays = $this->diffInDays($first);
     1106        foreach ([$second, ...$others] as $other) {
     1107            $otherDiffInDays = $this->diffInDays($other);
     1108            if ($otherDiffInDays < $closestDiffInDays) {
     1109                $closest = $other;
     1110                $closestDiffInDays = $otherDiffInDays;
     1111            }
     1112        }
     1113
     1114        return $closest;
     1115    }
     1116
     1117    /**
     1118     * Get the farthest date from the instance.
     1119     *
     1120     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate $first The instance to compare with.
     1121     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate $second The instance to compare with.
     1122     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate ...$others Others instance to compare with.
     1123     * @return self
     1124     */
     1125    public function farthest(ChronosDate $first, ChronosDate $second, ChronosDate ...$others): ChronosDate
     1126    {
     1127        $farthest = $first;
     1128        $farthestDiffInDays = $this->diffInDays($first);
     1129        foreach ([$second, ...$others] as $other) {
     1130            $otherDiffInDays = $this->diffInDays($other);
     1131            if ($otherDiffInDays > $farthestDiffInDays) {
     1132                $farthest = $other;
     1133                $farthestDiffInDays = $otherDiffInDays;
     1134            }
     1135        }
     1136
     1137        return $farthest;
     1138    }
     1139
     1140    /**
     1141     * Determines if the instance is a weekday
     1142     *
     1143     * @return bool
     1144     */
     1145    public function isWeekday(): bool
     1146    {
     1147        return !$this->isWeekend();
     1148    }
     1149
     1150    /**
     1151     * Determines if the instance is a weekend day
     1152     *
     1153     * @return bool
     1154     */
     1155    public function isWeekend(): bool
     1156    {
     1157        return in_array($this->dayOfWeek, Chronos::getWeekendDays(), true);
     1158    }
     1159
     1160    /**
     1161     * Determines if the instance is yesterday
     1162     *
     1163     * @param \DateTimeZone|string|null $timezone Time zone to use for now.
     1164     * @return bool
     1165     */
     1166    public function isYesterday(DateTimeZone|string|null $timezone = null): bool
     1167    {
     1168        return $this->equals(static::yesterday($timezone));
     1169    }
     1170
     1171    /**
     1172     * Determines if the instance is today
     1173     *
     1174     * @param \DateTimeZone|string|null $timezone Time zone to use for now.
     1175     * @return bool
     1176     */
     1177    public function isToday(DateTimeZone|string|null $timezone = null): bool
     1178    {
     1179        return $this->equals(static::now($timezone));
     1180    }
     1181
     1182    /**
     1183     * Determines if the instance is tomorrow
     1184     *
     1185     * @param \DateTimeZone|string|null $timezone Time zone to use for now.
     1186     * @return bool
     1187     */
     1188    public function isTomorrow(DateTimeZone|string|null $timezone = null): bool
     1189    {
     1190        return $this->equals(static::tomorrow($timezone));
     1191    }
     1192
     1193    /**
     1194     * Determines if the instance is within the next week
     1195     *
     1196     * @param \DateTimeZone|string|null $timezone Time zone to use for now.
     1197     * @return bool
     1198     */
     1199    public function isNextWeek(DateTimeZone|string|null $timezone = null): bool
     1200    {
     1201        return $this->format('W o') === static::now($timezone)->addWeeks(1)->format('W o');
     1202    }
     1203
     1204    /**
     1205     * Determines if the instance is within the last week
     1206     *
     1207     * @param \DateTimeZone|string|null $timezone Time zone to use for now.
     1208     * @return bool
     1209     */
     1210    public function isLastWeek(DateTimeZone|string|null $timezone = null): bool
     1211    {
     1212        return $this->format('W o') === static::now($timezone)->subWeeks(1)->format('W o');
     1213    }
     1214
     1215    /**
     1216     * Determines if the instance is within the next month
     1217     *
     1218     * @param \DateTimeZone|string|null $timezone Time zone to use for now.
     1219     * @return bool
     1220     */
     1221    public function isNextMonth(DateTimeZone|string|null $timezone = null): bool
     1222    {
     1223        return $this->format('m Y') === static::now($timezone)->addMonths(1)->format('m Y');
     1224    }
     1225
     1226    /**
     1227     * Determines if the instance is within the last month
     1228     *
     1229     * @param \DateTimeZone|string|null $timezone Time zone to use for now.
     1230     * @return bool
     1231     */
     1232    public function isLastMonth(DateTimeZone|string|null $timezone = null): bool
     1233    {
     1234        return $this->format('m Y') === static::now($timezone)->subMonths(1)->format('m Y');
     1235    }
     1236
     1237    /**
     1238     * Determines if the instance is within the next year
     1239     *
     1240     * @param \DateTimeZone|string|null $timezone Time zone to use for now.
     1241     * @return bool
     1242     */
     1243    public function isNextYear(DateTimeZone|string|null $timezone = null): bool
     1244    {
     1245        return $this->year === static::now($timezone)->addYears(1)->year;
     1246    }
     1247
     1248    /**
     1249     * Determines if the instance is within the last year
     1250     *
     1251     * @param \DateTimeZone|string|null $timezone Time zone to use for now.
     1252     * @return bool
     1253     */
     1254    public function isLastYear(DateTimeZone|string|null $timezone = null): bool
     1255    {
     1256        return $this->year === static::now($timezone)->subYears(1)->year;
     1257    }
     1258
     1259    /**
     1260     * Determines if the instance is within the first half of year
     1261     *
     1262     * @return bool
     1263     */
     1264    public function isFirstHalf(): bool
     1265    {
     1266        return $this->half === 1;
     1267    }
     1268
     1269    /**
     1270     * Determines if the instance is within the second half of year
     1271     *
     1272     * @return bool
     1273     */
     1274    public function isSecondHalf(): bool
     1275    {
     1276        return $this->half === 2;
     1277    }
     1278
     1279    /**
     1280     * Determines if the instance is in the future, ie. greater (after) than now
     1281     *
     1282     * @param \DateTimeZone|string|null $timezone Time zone to use for now.
     1283     * @return bool
     1284     */
     1285    public function isFuture(DateTimeZone|string|null $timezone = null): bool
     1286    {
     1287        return $this->greaterThan(static::now($timezone));
     1288    }
     1289
     1290    /**
     1291     * Determines if the instance is in the past, ie. less (before) than now
     1292     *
     1293     * @param \DateTimeZone|string|null $timezone Time zone to use for now.
     1294     * @return bool
     1295     */
     1296    public function isPast(DateTimeZone|string|null $timezone = null): bool
     1297    {
     1298        return $this->lessThan(static::now($timezone));
     1299    }
     1300
     1301    /**
     1302     * Determines if the instance is a leap year
     1303     *
     1304     * @return bool
     1305     */
     1306    public function isLeapYear(): bool
     1307    {
     1308        return $this->format('L') === '1';
     1309    }
     1310
     1311    /**
     1312     * Checks if this day is a Sunday.
     1313     *
     1314     * @return bool
     1315     */
     1316    public function isSunday(): bool
     1317    {
     1318        return $this->dayOfWeek === Chronos::SUNDAY;
     1319    }
     1320
     1321    /**
     1322     * Checks if this day is a Monday.
     1323     *
     1324     * @return bool
     1325     */
     1326    public function isMonday(): bool
     1327    {
     1328        return $this->dayOfWeek === Chronos::MONDAY;
     1329    }
     1330
     1331    /**
     1332     * Checks if this day is a Tuesday.
     1333     *
     1334     * @return bool
     1335     */
     1336    public function isTuesday(): bool
     1337    {
     1338        return $this->dayOfWeek === Chronos::TUESDAY;
     1339    }
     1340
     1341    /**
     1342     * Checks if this day is a Wednesday.
     1343     *
     1344     * @return bool
     1345     */
     1346    public function isWednesday(): bool
     1347    {
     1348        return $this->dayOfWeek === Chronos::WEDNESDAY;
     1349    }
     1350
     1351    /**
     1352     * Checks if this day is a Thursday.
     1353     *
     1354     * @return bool
     1355     */
     1356    public function isThursday(): bool
     1357    {
     1358        return $this->dayOfWeek === Chronos::THURSDAY;
     1359    }
     1360
     1361    /**
     1362     * Checks if this day is a Friday.
     1363     *
     1364     * @return bool
     1365     */
     1366    public function isFriday(): bool
     1367    {
     1368        return $this->dayOfWeek === Chronos::FRIDAY;
     1369    }
     1370
     1371    /**
     1372     * Checks if this day is a Saturday.
     1373     *
     1374     * @return bool
     1375     */
     1376    public function isSaturday(): bool
     1377    {
     1378        return $this->dayOfWeek === Chronos::SATURDAY;
     1379    }
     1380
     1381    /**
     1382     * Returns true this instance happened within the specified interval
     1383     *
     1384     * @param string|int $timeInterval the numeric value with space then time type.
     1385     *    Example of valid types: 6 hours, 2 days, 1 minute.
     1386     * @return bool
     1387     */
     1388    public function wasWithinLast(string|int $timeInterval): bool
     1389    {
     1390        $now = new static(new Chronos());
     1391        $interval = $now->modify('-' . $timeInterval);
     1392        $thisTime = $this->format('U');
     1393
     1394        return $thisTime >= $interval->format('U') && $thisTime <= $now->format('U');
     1395    }
     1396
     1397    /**
     1398     * Returns true this instance will happen within the specified interval
     1399     *
     1400     * @param string|int $timeInterval the numeric value with space then time type.
     1401     *    Example of valid types: 6 hours, 2 days, 1 minute.
     1402     * @return bool
     1403     */
     1404    public function isWithinNext(string|int $timeInterval): bool
     1405    {
     1406        $now = new static(new Chronos());
     1407        $interval = $now->modify('+' . $timeInterval);
     1408        $thisTime = $this->format('U');
     1409
     1410        return $thisTime <= $interval->format('U') && $thisTime >= $now->format('U');
     1411    }
     1412
     1413    /**
     1414     * Get the difference by the given interval using a filter callable
     1415     *
     1416     * @param \DateInterval $interval An interval to traverse by
     1417     * @param callable $callback The callback to use for filtering.
     1418     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate|null $other The instance to difference from.
     1419     * @param bool $absolute Get the absolute of the difference
     1420     * @param int $options DatePeriod options, {@see https://www.php.net/manual/en/class.dateperiod.php}
     1421     * @return int
     1422     */
     1423    public function diffFiltered(
     1424        DateInterval $interval,
     1425        callable $callback,
     1426        ?ChronosDate $other = null,
     1427        bool $absolute = true,
     1428        int $options = 0
     1429    ): int {
     1430        $start = $this;
     1431        $end = $other ?? new ChronosDate(Chronos::now());
     1432        $inverse = false;
     1433
     1434        if ($end < $start) {
     1435            $start = $end;
     1436            $end = $this;
     1437            $inverse = true;
     1438        }
     1439        // Hack around PHP's DatePeriod not counting equal dates at midnight as
     1440        // within the range. Sadly INCLUDE_END_DATE doesn't land until 8.2
     1441        $endTime = $end->native->modify('+1 second');
     1442
     1443        $period = new DatePeriod($start->native, $interval, $endTime, $options);
     1444        $vals = array_filter(iterator_to_array($period), function (DateTimeInterface $date) use ($callback) {
     1445            return $callback(static::parse($date));
     1446        });
     1447
     1448        $diff = count($vals);
     1449
     1450        return $inverse && !$absolute ? -$diff : $diff;
     1451    }
     1452
     1453    /**
     1454     * Get the difference in years
     1455     *
     1456     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate|null $other The instance to difference from.
     1457     * @param bool $absolute Get the absolute of the difference
     1458     * @return int
     1459     */
     1460    public function diffInYears(?ChronosDate $other = null, bool $absolute = true): int
     1461    {
     1462        $diff = $this->diff($other ?? new static(new Chronos()), $absolute);
     1463
     1464        return $diff->invert ? -$diff->y : $diff->y;
     1465    }
     1466
     1467    /**
     1468     * Get the difference in months
     1469     *
     1470     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate|null $other The instance to difference from.
     1471     * @param bool $absolute Get the absolute of the difference
     1472     * @return int
     1473     */
     1474    public function diffInMonths(?ChronosDate $other = null, bool $absolute = true): int
     1475    {
     1476        $diff = $this->diff($other ?? new static(Chronos::now()), $absolute);
     1477        $months = $diff->y * Chronos::MONTHS_PER_YEAR + $diff->m;
     1478
     1479        return $diff->invert ? -$months : $months;
     1480    }
     1481
     1482    /**
     1483     * Get the difference in weeks
     1484     *
     1485     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate|null $other The instance to difference from.
     1486     * @param bool $absolute Get the absolute of the difference
     1487     * @return int
     1488     */
     1489    public function diffInWeeks(?ChronosDate $other = null, bool $absolute = true): int
     1490    {
     1491        return (int)($this->diffInDays($other, $absolute) / Chronos::DAYS_PER_WEEK);
     1492    }
     1493
     1494    /**
     1495     * Get the difference in days
     1496     *
     1497     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate|null $other The instance to difference from.
     1498     * @param bool $absolute Get the absolute of the difference
     1499     * @return int
     1500     */
     1501    public function diffInDays(?ChronosDate $other = null, bool $absolute = true): int
     1502    {
     1503        $diff = $this->diff($other ?? new static(Chronos::now()), $absolute);
     1504
     1505        return $diff->invert ? -(int)$diff->days : (int)$diff->days;
     1506    }
     1507
     1508    /**
     1509     * Get the difference in days using a filter callable
     1510     *
     1511     * @param callable $callback The callback to use for filtering.
     1512     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate|null $other The instance to difference from.
     1513     * @param bool $absolute Get the absolute of the difference
     1514     * @param int $options DatePeriod options, {@see https://www.php.net/manual/en/class.dateperiod.php}
     1515     * @return int
     1516     */
     1517    public function diffInDaysFiltered(
     1518        callable $callback,
     1519        ?ChronosDate $other = null,
     1520        bool $absolute = true,
     1521        int $options = 0
     1522    ): int {
     1523        return $this->diffFiltered(new DateInterval('P1D'), $callback, $other, $absolute, $options);
     1524    }
     1525
     1526    /**
     1527     * Get the difference in weekdays
     1528     *
     1529     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate|null $other The instance to difference from.
     1530     * @param bool $absolute Get the absolute of the difference
     1531     * @param int $options DatePeriod options, {@see https://www.php.net/manual/en/class.dateperiod.php}
     1532     * @return int
     1533     */
     1534    public function diffInWeekdays(?ChronosDate $other = null, bool $absolute = true, int $options = 0): int
     1535    {
     1536        return $this->diffInDaysFiltered(function (ChronosDate $date) {
     1537            return $date->isWeekday();
     1538        }, $other, $absolute, $options);
     1539    }
     1540
     1541    /**
     1542     * Get the difference in weekend days using a filter
     1543     *
     1544     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate|null $other The instance to difference from.
     1545     * @param bool $absolute Get the absolute of the difference
     1546     * @param int $options DatePeriod options, {@see https://www.php.net/manual/en/class.dateperiod.php}
     1547     * @return int
     1548     */
     1549    public function diffInWeekendDays(?ChronosDate $other = null, bool $absolute = true, int $options = 0): int
     1550    {
     1551        return $this->diffInDaysFiltered(function (ChronosDate $date) {
     1552            return $date->isWeekend();
     1553        }, $other, $absolute, $options);
     1554    }
     1555
     1556    /**
     1557     * Get the difference in a human readable format.
     1558     *
     1559     * When comparing a value in the past to default now:
     1560     * 5 months ago
     1561     *
     1562     * When comparing a value in the future to default now:
     1563     * 5 months from now
     1564     *
     1565     * When comparing a value in the past to another value:
     1566     * 5 months before
     1567     *
     1568     * When comparing a value in the future to another value:
     1569     * 5 months after
     1570     *
     1571     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate|null $other The datetime to compare with.
     1572     * @param bool $absolute removes difference modifiers ago, after, etc
     1573     * @return string
     1574     */
     1575    public function diffForHumans(?ChronosDate $other = null, bool $absolute = false): string
     1576    {
     1577        return static::diffFormatter()->diffForHumans($this, $other, $absolute);
     1578    }
     1579
     1580    /**
     1581     * Returns the date as a `DateTimeImmutable` instance at midnight.
     1582     *
     1583     * @param \DateTimeZone|string|null $timezone Time zone the DateTimeImmutable instance will be in
     1584     * @return \DateTimeImmutable
     1585     */
     1586    public function toDateTimeImmutable(DateTimeZone|string|null $timezone = null): DateTimeImmutable
     1587    {
     1588        if ($timezone === null) {
     1589            return $this->native;
     1590        }
     1591
     1592        $timezone = is_string($timezone) ? new DateTimeZone($timezone) : $timezone;
     1593
     1594        return new DateTimeImmutable($this->native->format('Y-m-d H:i:s.u'), $timezone);
     1595    }
     1596
     1597    /**
     1598     * Returns the date as a `DateTimeImmutable` instance at midnight.
     1599     *
     1600     * Alias of `toDateTimeImmutable()`.
     1601     *
     1602     * @param \DateTimeZone|string|null $timezone Time zone the DateTimeImmutable instance will be in
     1603     * @return \DateTimeImmutable
     1604     */
     1605    public function toNative(DateTimeZone|string|null $timezone = null): DateTimeImmutable
     1606    {
     1607        return $this->toDateTimeImmutable($timezone);
     1608    }
     1609
     1610    /**
     1611     * Get a part of the object
     1612     *
     1613     * @param string $name The property name to read.
     1614     * @return string|float|int|bool The property value.
     1615     * @throws \InvalidArgumentException
     1616     */
     1617    public function __get(string $name): string|float|int|bool
     1618    {
     1619        static $formats = [
     1620            'year' => 'Y',
     1621            'yearIso' => 'o',
     1622            'month' => 'n',
     1623            'day' => 'j',
     1624            'dayOfWeek' => 'N',
     1625            'dayOfYear' => 'z',
     1626            'weekOfYear' => 'W',
     1627            'daysInMonth' => 't',
     1628        ];
     1629
     1630        switch (true) {
     1631            case isset($formats[$name]):
     1632                return (int)$this->format($formats[$name]);
     1633
     1634            case $name === 'dayOfWeekName':
     1635                return $this->format('l');
     1636
     1637            case $name === 'weekOfMonth':
     1638                return (int)ceil($this->day / Chronos::DAYS_PER_WEEK);
     1639
     1640            case $name === 'age':
     1641                return $this->diffInYears();
     1642
     1643            case $name === 'quarter':
     1644                return (int)ceil($this->month / 3);
     1645
     1646            case $name === 'half':
     1647                return $this->month <= 6 ? 1 : 2;
     1648
     1649            default:
     1650                throw new InvalidArgumentException(sprintf('Unknown getter `%s`', $name));
     1651        }
     1652    }
     1653
     1654    /**
     1655     * Check if an attribute exists on the object
     1656     *
     1657     * @param string $name The property name to check.
     1658     * @return bool Whether the property exists.
     1659     */
     1660    public function __isset(string $name): bool
     1661    {
     1662        try {
     1663            $this->__get($name);
     1664        } catch (InvalidArgumentException $e) {
     1665            return false;
     1666        }
     1667
     1668        return true;
    1291669    }
    1301670
     
    1371677    {
    1381678        $properties = [
    139             'hasFixedNow' => static::hasTestNow(),
     1679            'hasFixedNow' => Chronos::hasTestNow(),
    1401680            'date' => $this->format('Y-m-d'),
    1411681        ];
     
    1431683        return $properties;
    1441684    }
    145 
    146     /**
    147      * Create an instance from a specific date.
    148      *
    149      * @param ?int $year The year to create an instance with.
    150      * @param ?int $month The month to create an instance with.
    151      * @param ?int $day The day to create an instance with.
    152      * @return static
    153      */
    154     public static function create(?int $year = null, ?int $month = null, ?int $day = null)
    155     {
    156         $now = static::today();
    157         $year = $year ?? (int)$now->format('Y');
    158         $month = $month ?? $now->format('m');
    159         $day = $day ?? $now->format('d');
    160 
    161         $instance = static::createFromFormat(
    162             'Y-m-d',
    163             sprintf('%s-%s-%s', 0, $month, $day)
    164         );
    165 
    166         return $instance->addYears($year);
    167     }
    168 
    169     /**
    170      * Add an Interval to a Date
    171      *
    172      * Any changes to the time will cause an exception to be raised.
    173      *
    174      * @param \DateInterval $interval The interval to modify this date by.
    175      * @return static A modified Date instance
    176      */
    177     #[\ReturnTypeWillChange]
    178     public function add($interval)
    179     {
    180         if ($interval->f > 0 || $interval->s > 0 || $interval->i > 0 || $interval->h > 0) {
    181             trigger_error('2.5 Adding intervals with time components will be removed in 3.0', E_USER_DEPRECATED);
    182         }
    183 
    184         return parent::add($interval)->setTime(0, 0, 0);
    185     }
    186 
    187     /**
    188      * Subtract an Interval from a Date.
    189      *
    190      * Any changes to the time will cause an exception to be raised.
    191      *
    192      * @param \DateInterval $interval The interval to modify this date by.
    193      * @return static A modified Date instance
    194      */
    195     #[\ReturnTypeWillChange]
    196     public function sub($interval)
    197     {
    198         if ($interval->f > 0 || $interval->s > 0 || $interval->i > 0 || $interval->h > 0) {
    199             trigger_error('2.5 Subtracting intervals with time components will be removed in 3.0', E_USER_DEPRECATED);
    200         }
    201 
    202         return parent::sub($interval)->setTime(0, 0, 0);
    203     }
    204 
    205     /**
    206      * Creates a new instance with date modified according to DateTimeImmutable::modifier().
    207      *
    208      * Attempting to change a time component will raise an exception
    209      *
    210      * @param string $modifier Date modifier
    211      * @return static
    212      */
    213     #[\ReturnTypeWillChange]
    214     public function modify($modifier)
    215     {
    216         if (preg_match('/hour|minute|second/', $modifier)) {
    217             trigger_error('2.5 Modifying dates with time values will be removed in 3.0', E_USER_DEPRECATED);
    218         }
    219 
    220         $new = parent::modify($modifier);
    221         if ($new === false) {
    222             throw new InvalidArgumentException('Unable to modify date using: ' . $modifier);
    223         }
    224 
    225         if ($new->format('H:i:s') !== '00:00:00') {
    226             $new = $new->setTime(0, 0, 0);
    227         }
    228 
    229         return $new;
    230     }
    231 
    232     /**
    233      * @inheritDoc
    234      */
    235     #[\ReturnTypeWillChange]
    236     public function setTimestamp($value)
    237     {
    238         trigger_error('2.5 Setting timestamp values on Date values will be removed in 3.0', E_USER_DEPRECATED);
    239 
    240         return parent::setTimestamp($value);
    241     }
    242 
    243     /**
    244      * @inheritDoc
    245      */
    246     public function hour(int $value): ChronosInterface
    247     {
    248         trigger_error('2.5 Modifying hours on Date values will be removed in 3.0', E_USER_DEPRECATED);
    249 
    250         return $this->setTime($value, $this->minute, $this->second);
    251     }
    252 
    253     /**
    254      * Set the instance's minute
    255      *
    256      * @param int $value The minute value.
    257      * @return static
    258      */
    259     public function minute(int $value): ChronosInterface
    260     {
    261         trigger_error('2.5 Modifying minutes on Date values will be removed in 3.0', E_USER_DEPRECATED);
    262 
    263         return $this->setTime($this->hour, $value, $this->second);
    264     }
    265 
    266     /**
    267      * Set the instance's second
    268      *
    269      * @param int $value The seconds value.
    270      * @return static
    271      */
    272     public function second(int $value): ChronosInterface
    273     {
    274         trigger_error('2.5 Modifying second on Date values will be removed in 3.0', E_USER_DEPRECATED);
    275 
    276         return $this->setTime($this->hour, $this->minute, $value);
    277     }
    278 
    279     /**
    280      * Set the instance's microsecond
    281      *
    282      * @param int $value The microsecond value.
    283      * @return static
    284      */
    285     public function microsecond(int $value): ChronosInterface
    286     {
    287         trigger_error('2.5 Modifying microsecond on Date values will be removed in 3.0', E_USER_DEPRECATED);
    288 
    289         return $this->setTime($this->hour, $this->minute, $this->second, $value);
    290     }
    2911685}
    292 
    293 class_alias('FakerPress\ThirdParty\Cake\Chronos\ChronosDate', 'FakerPress\ThirdParty\Cake\Chronos\Date');
  • fakerpress/tags/0.8.0/vendor-prefixed/cakephp/chronos/src/DifferenceFormatter.php

    r3296016 r3297704  
    1515namespace FakerPress\ThirdParty\Cake\Chronos;
    1616
     17use DateTimeInterface;
     18
    1719/**
    1820 * Handles formatting differences in text.
     
    2022 * Provides a swappable component for other libraries to leverage.
    2123 * when localizing or customizing the difference output.
     24 *
     25 * @internal
    2226 */
    2327class DifferenceFormatter implements DifferenceFormatterInterface
     
    2832     * @var \FakerPress\ThirdParty\Cake\Chronos\Translator
    2933     */
    30     protected $translate;
     34    protected Translator $translate;
    3135
    3236    /**
     
    4145
    4246    /**
    43      * Get the difference in a human readable format.
    44      *
    45      * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosInterface $date The datetime to start with.
    46      * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosInterface|null $other The datetime to compare against.
    47      * @param bool $absolute removes time difference modifiers ago, after, etc
    48      * @return string The difference between the two days in a human readable format
    49      * @see \FakerPress\ThirdParty\Cake\Chronos\ChronosInterface::diffForHumans
     47     * @inheritDoc
    5048     */
    5149    public function diffForHumans(
    52         ChronosInterface $date,
    53         ?ChronosInterface $other = null,
     50        ChronosDate|DateTimeInterface $first,
     51        ChronosDate|DateTimeInterface|null $second = null,
    5452        bool $absolute = false
    5553    ): string {
    56         $isNow = $other === null;
    57         if ($isNow) {
    58             $other = $date->now($date->tz);
     54        $isNow = $second === null;
     55        if ($second === null) {
     56            if ($first instanceof ChronosDate) {
     57                $second = new ChronosDate(Chronos::now());
     58            } else {
     59                $second = Chronos::now($first->getTimezone());
     60            }
    5961        }
    60         $diffInterval = $date->diff($other);
     62        assert(
     63            ($first instanceof ChronosDate && $second instanceof ChronosDate) ||
     64            ($first instanceof DateTimeInterface && $second instanceof DateTimeInterface)
     65        );
     66
     67        $diffInterval = $first->diff($second);
    6168
    6269        switch (true) {
     
    6976                $count = $diffInterval->m;
    7077                break;
    71             case $diffInterval->days >= ChronosInterface::DAYS_PER_WEEK * 3:
     78            case $diffInterval->days >= Chronos::DAYS_PER_WEEK * 3:
    7279                $unit = 'week';
    73                 $count = (int)($diffInterval->days / ChronosInterface::DAYS_PER_WEEK);
     80                $count = (int)($diffInterval->days / Chronos::DAYS_PER_WEEK);
    7481                break;
    7582            case $diffInterval->d > 0:
  • fakerpress/tags/0.8.0/vendor-prefixed/cakephp/chronos/src/DifferenceFormatterInterface.php

    r3296016 r3297704  
    1414namespace FakerPress\ThirdParty\Cake\Chronos;
    1515
     16use DateTimeInterface;
     17
    1618/**
    1719 * Interface for formatting differences in text.
     
    2224     * Get the difference in a human readable format.
    2325     *
    24      * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosInterface $date The datetime to start with.
    25      * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosInterface|null $other The datetime to compare against.
    26      * @param bool $absolute Removes time difference modifiers ago, after, etc.
    27      * @return string The difference between the two days in a human readable format.
    28      * @see \FakerPress\ThirdParty\Cake\Chronos\ChronosInterface::diffForHumans
     26     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate|\DateTimeInterface $first The datetime to start with.
     27     * @param \FakerPress\ThirdParty\Cake\Chronos\ChronosDate|\DateTimeInterface|null $second The datetime to compare against.
     28     * @param bool $absolute removes time difference modifiers ago, after, etc
     29     * @return string The difference between the two days in a human readable format
    2930     */
    3031    public function diffForHumans(
    31         ChronosInterface $date,
    32         ?ChronosInterface $other = null,
     32        ChronosDate|DateTimeInterface $first,
     33        ChronosDate|DateTimeInterface|null $second = null,
    3334        bool $absolute = false
    3435    ): string;
  • fakerpress/tags/0.8.0/vendor-prefixed/cakephp/chronos/src/Translator.php

    r3296016 r3297704  
    1616/**
    1717 * Basic english only 'translator' for diffForHumans()
     18 *
     19 * @internal
    1820 */
    1921class Translator
     
    2426     * @var array
    2527     */
    26     public static $strings = [
     28    public static array $strings = [
    2729        'year' => '1 year',
    2830        'year_plural' => '{count} years',
     
    4951     *
    5052     * @param string $key The key to check.
    51      * @return bool Whether or not the key exists.
     53     * @return bool Whether the key exists.
    5254     */
    5355    public function exists(string $key): bool
  • fakerpress/tags/0.8.0/vendor-prefixed/composer/autoload_classmap.php

    r3296016 r3297704  
    6161    'FakerPress\\ThirdParty\\Cake\\Chronos\\Chronos' => $vendorDir . '/cakephp/chronos/src/Chronos.php',
    6262    'FakerPress\\ThirdParty\\Cake\\Chronos\\ChronosDate' => $vendorDir . '/cakephp/chronos/src/ChronosDate.php',
    63     'FakerPress\\ThirdParty\\Cake\\Chronos\\ChronosInterface' => $vendorDir . '/cakephp/chronos/src/ChronosInterface.php',
    64     'FakerPress\\ThirdParty\\Cake\\Chronos\\ChronosInterval' => $vendorDir . '/cakephp/chronos/src/ChronosInterval.php',
     63    'FakerPress\\ThirdParty\\Cake\\Chronos\\ChronosTime' => $vendorDir . '/cakephp/chronos/src/ChronosTime.php',
     64    'FakerPress\\ThirdParty\\Cake\\Chronos\\ClockFactory' => $vendorDir . '/cakephp/chronos/src/ClockFactory.php',
    6565    'FakerPress\\ThirdParty\\Cake\\Chronos\\DifferenceFormatter' => $vendorDir . '/cakephp/chronos/src/DifferenceFormatter.php',
    6666    'FakerPress\\ThirdParty\\Cake\\Chronos\\DifferenceFormatterInterface' => $vendorDir . '/cakephp/chronos/src/DifferenceFormatterInterface.php',
    67     'FakerPress\\ThirdParty\\Cake\\Chronos\\MutableDate' => $vendorDir . '/cakephp/chronos/src/MutableDate.php',
    68     'FakerPress\\ThirdParty\\Cake\\Chronos\\MutableDateTime' => $vendorDir . '/cakephp/chronos/src/MutableDateTime.php',
    69     'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\ComparisonTrait' => $vendorDir . '/cakephp/chronos/src/Traits/ComparisonTrait.php',
    70     'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\CopyTrait' => $vendorDir . '/cakephp/chronos/src/Traits/CopyTrait.php',
    71     'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\DifferenceTrait' => $vendorDir . '/cakephp/chronos/src/Traits/DifferenceTrait.php',
    72     'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\FactoryTrait' => $vendorDir . '/cakephp/chronos/src/Traits/FactoryTrait.php',
    73     'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\FormattingTrait' => $vendorDir . '/cakephp/chronos/src/Traits/FormattingTrait.php',
    74     'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\FrozenTimeTrait' => $vendorDir . '/cakephp/chronos/src/Traits/FrozenTimeTrait.php',
    75     'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\MagicPropertyTrait' => $vendorDir . '/cakephp/chronos/src/Traits/MagicPropertyTrait.php',
    76     'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\ModifierTrait' => $vendorDir . '/cakephp/chronos/src/Traits/ModifierTrait.php',
    77     'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\RelativeKeywordTrait' => $vendorDir . '/cakephp/chronos/src/Traits/RelativeKeywordTrait.php',
    78     'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\TestingAidTrait' => $vendorDir . '/cakephp/chronos/src/Traits/TestingAidTrait.php',
    79     'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\TimezoneTrait' => $vendorDir . '/cakephp/chronos/src/Traits/TimezoneTrait.php',
     67    'FakerPress\\ThirdParty\\Cake\\Chronos\\FormattingTrait' => $vendorDir . '/cakephp/chronos/src/FormattingTrait.php',
    8068    'FakerPress\\ThirdParty\\Cake\\Chronos\\Translator' => $vendorDir . '/cakephp/chronos/src/Translator.php',
    8169    'FakerPress\\ThirdParty\\Faker\\Calculator\\Ean' => $vendorDir . '/fakerphp/faker/src/Faker/Calculator/Ean.php',
     
    585573    'FakerPress\\ThirdParty\\Faker\\UniqueGenerator' => $vendorDir . '/fakerphp/faker/src/Faker/UniqueGenerator.php',
    586574    'FakerPress\\ThirdParty\\Faker\\ValidGenerator' => $vendorDir . '/fakerphp/faker/src/Faker/ValidGenerator.php',
     575    'FakerPress\\ThirdParty\\Psr\\Clock\\ClockInterface' => $vendorDir . '/psr/clock/src/ClockInterface.php',
    587576    'FakerPress\\ThirdParty\\Psr\\Container\\ContainerExceptionInterface' => $vendorDir . '/psr/container/src/ContainerExceptionInterface.php',
    588577    'FakerPress\\ThirdParty\\Psr\\Container\\ContainerInterface' => $vendorDir . '/psr/container/src/ContainerInterface.php',
  • fakerpress/tags/0.8.0/vendor-prefixed/composer/autoload_files.php

    r3296016 r3297704  
    88return array(
    99    '009ddd489b3d26de464d8a67be8b5b8d' => $vendorDir . '/symfony/deprecation-contracts/function.php',
    10     'f206c1ad269197be98211b6d5caa3df2' => $vendorDir . '/cakephp/chronos/src/carbon_compat.php',
    1110    'fa3de58b547e61bb6f7509ef1b3565d0' => $baseDir . '/src/functions/container.php',
    1211    '0294eb11e5c3d538e54579e15eec6543' => $baseDir . '/src/functions/date.php',
  • fakerpress/tags/0.8.0/vendor-prefixed/composer/autoload_psr4.php

    r3296016 r3297704  
    99    'FakerPress\\ThirdParty\\lucatume\\DI52\\' => array($vendorDir . '/lucatume/di52/src'),
    1010    'FakerPress\\ThirdParty\\Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
     11    'FakerPress\\ThirdParty\\Psr\\Clock\\' => array($vendorDir . '/psr/clock/src'),
    1112    'FakerPress\\ThirdParty\\Faker\\' => array($vendorDir . '/fakerphp/faker/src/Faker'),
    1213    'FakerPress\\ThirdParty\\Cake\\Chronos\\' => array($vendorDir . '/cakephp/chronos/src'),
  • fakerpress/tags/0.8.0/vendor-prefixed/composer/autoload_real.php

    r3296016 r3297704  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInitd4e0679c57019ad4f73ecb3ba581bb5c
     5class ComposerAutoloaderInit5dc28f99f9a111df9987bee394b31be9
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInitd4e0679c57019ad4f73ecb3ba581bb5c', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInit5dc28f99f9a111df9987bee394b31be9', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \FakerPress\ThirdParty\Composer\Autoload\ClassLoader(\dirname(__DIR__));
    29         spl_autoload_unregister(array('ComposerAutoloaderInitd4e0679c57019ad4f73ecb3ba581bb5c', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInit5dc28f99f9a111df9987bee394b31be9', 'loadClassLoader'));
    3030
    3131        require __DIR__ . '/autoload_static.php';
    32         call_user_func(\FakerPress\ThirdParty\Composer\Autoload\ComposerStaticInitd4e0679c57019ad4f73ecb3ba581bb5c::getInitializer($loader));
     32        call_user_func(\FakerPress\ThirdParty\Composer\Autoload\ComposerStaticInit5dc28f99f9a111df9987bee394b31be9::getInitializer($loader));
    3333
    3434        $loader->setClassMapAuthoritative(true);
    3535        $loader->register(true);
    3636
    37         $filesToLoad = \FakerPress\ThirdParty\Composer\Autoload\ComposerStaticInitd4e0679c57019ad4f73ecb3ba581bb5c::$files;
     37        $filesToLoad = \FakerPress\ThirdParty\Composer\Autoload\ComposerStaticInit5dc28f99f9a111df9987bee394b31be9::$files;
    3838        $requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
    3939            if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • fakerpress/tags/0.8.0/vendor-prefixed/composer/autoload_static.php

    r3296016 r3297704  
    55namespace FakerPress\ThirdParty\Composer\Autoload;
    66
    7 class ComposerStaticInitd4e0679c57019ad4f73ecb3ba581bb5c
     7class ComposerStaticInit5dc28f99f9a111df9987bee394b31be9
    88{
    99    public static $files = array (
    1010        '009ddd489b3d26de464d8a67be8b5b8d' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
    11         'f206c1ad269197be98211b6d5caa3df2' => __DIR__ . '/..' . '/cakephp/chronos/src/carbon_compat.php',
    1211        'acf157317f3f02fa89a9c2026d9a35a7' => __DIR__ . '/../..' . '/src/functions/container.php',
    1312        'a1025652e8fd8237c706c17e8b59b740' => __DIR__ . '/../..' . '/src/functions/date.php',
     
    2322            'FakerPress\\ThirdParty\\lucatume\\DI52\\' => 36,
    2423            'FakerPress\\ThirdParty\\Psr\\Container\\' => 36,
     24            'FakerPress\\ThirdParty\\Psr\\Clock\\' => 32,
    2525            'FakerPress\\ThirdParty\\Faker\\' => 28,
    2626            'FakerPress\\ThirdParty\\Cake\\Chronos\\' => 35,
     
    3838        array (
    3939            0 => __DIR__ . '/..' . '/psr/container/src',
     40        ),
     41        'FakerPress\\ThirdParty\\Psr\\Clock\\' =>
     42        array (
     43            0 => __DIR__ . '/..' . '/psr/clock/src',
    4044        ),
    4145        'FakerPress\\ThirdParty\\Faker\\' =>
     
    112116        'FakerPress\\ThirdParty\\Cake\\Chronos\\Chronos' => __DIR__ . '/..' . '/cakephp/chronos/src/Chronos.php',
    113117        'FakerPress\\ThirdParty\\Cake\\Chronos\\ChronosDate' => __DIR__ . '/..' . '/cakephp/chronos/src/ChronosDate.php',
    114         'FakerPress\\ThirdParty\\Cake\\Chronos\\ChronosInterface' => __DIR__ . '/..' . '/cakephp/chronos/src/ChronosInterface.php',
    115         'FakerPress\\ThirdParty\\Cake\\Chronos\\ChronosInterval' => __DIR__ . '/..' . '/cakephp/chronos/src/ChronosInterval.php',
     118        'FakerPress\\ThirdParty\\Cake\\Chronos\\ChronosTime' => __DIR__ . '/..' . '/cakephp/chronos/src/ChronosTime.php',
     119        'FakerPress\\ThirdParty\\Cake\\Chronos\\ClockFactory' => __DIR__ . '/..' . '/cakephp/chronos/src/ClockFactory.php',
    116120        'FakerPress\\ThirdParty\\Cake\\Chronos\\DifferenceFormatter' => __DIR__ . '/..' . '/cakephp/chronos/src/DifferenceFormatter.php',
    117121        'FakerPress\\ThirdParty\\Cake\\Chronos\\DifferenceFormatterInterface' => __DIR__ . '/..' . '/cakephp/chronos/src/DifferenceFormatterInterface.php',
    118         'FakerPress\\ThirdParty\\Cake\\Chronos\\MutableDate' => __DIR__ . '/..' . '/cakephp/chronos/src/MutableDate.php',
    119         'FakerPress\\ThirdParty\\Cake\\Chronos\\MutableDateTime' => __DIR__ . '/..' . '/cakephp/chronos/src/MutableDateTime.php',
    120         'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\ComparisonTrait' => __DIR__ . '/..' . '/cakephp/chronos/src/Traits/ComparisonTrait.php',
    121         'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\CopyTrait' => __DIR__ . '/..' . '/cakephp/chronos/src/Traits/CopyTrait.php',
    122         'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\DifferenceTrait' => __DIR__ . '/..' . '/cakephp/chronos/src/Traits/DifferenceTrait.php',
    123         'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\FactoryTrait' => __DIR__ . '/..' . '/cakephp/chronos/src/Traits/FactoryTrait.php',
    124         'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\FormattingTrait' => __DIR__ . '/..' . '/cakephp/chronos/src/Traits/FormattingTrait.php',
    125         'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\FrozenTimeTrait' => __DIR__ . '/..' . '/cakephp/chronos/src/Traits/FrozenTimeTrait.php',
    126         'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\MagicPropertyTrait' => __DIR__ . '/..' . '/cakephp/chronos/src/Traits/MagicPropertyTrait.php',
    127         'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\ModifierTrait' => __DIR__ . '/..' . '/cakephp/chronos/src/Traits/ModifierTrait.php',
    128         'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\RelativeKeywordTrait' => __DIR__ . '/..' . '/cakephp/chronos/src/Traits/RelativeKeywordTrait.php',
    129         'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\TestingAidTrait' => __DIR__ . '/..' . '/cakephp/chronos/src/Traits/TestingAidTrait.php',
    130         'FakerPress\\ThirdParty\\Cake\\Chronos\\Traits\\TimezoneTrait' => __DIR__ . '/..' . '/cakephp/chronos/src/Traits/TimezoneTrait.php',
     122        'FakerPress\\ThirdParty\\Cake\\Chronos\\FormattingTrait' => __DIR__ . '/..' . '/cakephp/chronos/src/FormattingTrait.php',
    131123        'FakerPress\\ThirdParty\\Cake\\Chronos\\Translator' => __DIR__ . '/..' . '/cakephp/chronos/src/Translator.php',
    132124        'FakerPress\\ThirdParty\\Faker\\Calculator\\Ean' => __DIR__ . '/..' . '/fakerphp/faker/src/Faker/Calculator/Ean.php',
     
    636628        'FakerPress\\ThirdParty\\Faker\\UniqueGenerator' => __DIR__ . '/..' . '/fakerphp/faker/src/Faker/UniqueGenerator.php',
    637629        'FakerPress\\ThirdParty\\Faker\\ValidGenerator' => __DIR__ . '/..' . '/fakerphp/faker/src/Faker/ValidGenerator.php',
     630        'FakerPress\\ThirdParty\\Psr\\Clock\\ClockInterface' => __DIR__ . '/..' . '/psr/clock/src/ClockInterface.php',
    638631        'FakerPress\\ThirdParty\\Psr\\Container\\ContainerExceptionInterface' => __DIR__ . '/..' . '/psr/container/src/ContainerExceptionInterface.php',
    639632        'FakerPress\\ThirdParty\\Psr\\Container\\ContainerInterface' => __DIR__ . '/..' . '/psr/container/src/ContainerInterface.php',
     
    661654    {
    662655        return \Closure::bind(function () use ($loader) {
    663             $loader->prefixLengthsPsr4 = ComposerStaticInitd4e0679c57019ad4f73ecb3ba581bb5c::$prefixLengthsPsr4;
    664             $loader->prefixDirsPsr4 = ComposerStaticInitd4e0679c57019ad4f73ecb3ba581bb5c::$prefixDirsPsr4;
    665             $loader->classMap = ComposerStaticInitd4e0679c57019ad4f73ecb3ba581bb5c::$classMap;
     656            $loader->prefixLengthsPsr4 = ComposerStaticInit5dc28f99f9a111df9987bee394b31be9::$prefixLengthsPsr4;
     657            $loader->prefixDirsPsr4 = ComposerStaticInit5dc28f99f9a111df9987bee394b31be9::$prefixDirsPsr4;
     658            $loader->classMap = ComposerStaticInit5dc28f99f9a111df9987bee394b31be9::$classMap;
    666659
    667660        }, null, ClassLoader::class);
  • fakerpress/tags/0.8.0/vendor-prefixed/composer/installed.json

    r3296016 r3297704  
    33        {
    44            "name": "cakephp/chronos",
    5             "version": "2.4.5",
    6             "version_normalized": "2.4.5.0",
     5            "version": "3.1.0",
     6            "version_normalized": "3.1.0.0",
    77            "source": {
    88                "type": "git",
    99                "url": "https://github.com/cakephp/chronos.git",
    10                 "reference": "b0321ab7658af9e7abcb3dd876f226e6f3dbb81f"
    11             },
    12             "dist": {
    13                 "type": "zip",
    14                 "url": "https://api.github.com/repos/cakephp/chronos/zipball/b0321ab7658af9e7abcb3dd876f226e6f3dbb81f",
    15                 "reference": "b0321ab7658af9e7abcb3dd876f226e6f3dbb81f",
    16                 "shasum": ""
    17             },
    18             "require": {
    19                 "php": ">=7.2"
     10                "reference": "786d69e1ee4b735765cbdb5521b9603e9b98d650"
     11            },
     12            "dist": {
     13                "type": "zip",
     14                "url": "https://api.github.com/repos/cakephp/chronos/zipball/786d69e1ee4b735765cbdb5521b9603e9b98d650",
     15                "reference": "786d69e1ee4b735765cbdb5521b9603e9b98d650",
     16                "shasum": ""
     17            },
     18            "require": {
     19                "php": ">=8.1",
     20                "psr/clock": "^1.0"
     21            },
     22            "provide": {
     23                "psr/clock-implementation": "1.0"
    2024            },
    2125            "require-dev": {
    22                 "cakephp/cakephp-codesniffer": "^4.5",
    23                 "phpunit/phpunit": "^8.0 || ^9.0"
    24             },
    25             "time": "2024-07-30T22:26:11+00:00",
    26             "type": "library",
    27             "installation-source": "dist",
    28             "autoload": {
    29                 "files": [
    30                     "src/carbon_compat.php"
    31                 ],
     26                "cakephp/cakephp-codesniffer": "^5.0",
     27                "phpunit/phpunit": "^10.1.0 || ^11.1.3"
     28            },
     29            "time": "2024-07-18T03:18:04+00:00",
     30            "type": "library",
     31            "installation-source": "dist",
     32            "autoload": {
    3233                "psr-4": {
    3334                    "FakerPress\\ThirdParty\\Cake\\Chronos\\": "src/"
     
    175176            },
    176177            "install-path": "../../vendor-prefixed/lucatume/di52/"
     178        },
     179        {
     180            "name": "psr/clock",
     181            "version": "1.0.0",
     182            "version_normalized": "1.0.0.0",
     183            "source": {
     184                "type": "git",
     185                "url": "https://github.com/php-fig/clock.git",
     186                "reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d"
     187            },
     188            "dist": {
     189                "type": "zip",
     190                "url": "https://api.github.com/repos/php-fig/clock/zipball/e41a24703d4560fd0acb709162f73b8adfc3aa0d",
     191                "reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d",
     192                "shasum": ""
     193            },
     194            "require": {
     195                "php": "^7.0 || ^8.0"
     196            },
     197            "time": "2022-11-25T14:36:26+00:00",
     198            "type": "library",
     199            "installation-source": "dist",
     200            "autoload": {
     201                "psr-4": {
     202                    "FakerPress\\ThirdParty\\Psr\\Clock\\": "src/"
     203                }
     204            },
     205            "notification-url": "https://packagist.org/downloads/",
     206            "license": [
     207                "MIT"
     208            ],
     209            "authors": [
     210                {
     211                    "name": "PHP-FIG",
     212                    "homepage": "https://www.php-fig.org/"
     213                }
     214            ],
     215            "description": "Common interface for reading the clock.",
     216            "homepage": "https://github.com/php-fig/clock",
     217            "keywords": [
     218                "clock",
     219                "now",
     220                "psr",
     221                "psr-20",
     222                "time"
     223            ],
     224            "support": {
     225                "issues": "https://github.com/php-fig/clock/issues",
     226                "source": "https://github.com/php-fig/clock/tree/1.0.0"
     227            },
     228            "install-path": "../../vendor-prefixed/psr/clock/"
    177229        },
    178230        {
     
    229281        {
    230282            "name": "symfony/deprecation-contracts",
    231             "version": "v2.5.4",
    232             "version_normalized": "2.5.4.0",
     283            "version": "v3.5.1",
     284            "version_normalized": "3.5.1.0",
    233285            "source": {
    234286                "type": "git",
    235287                "url": "https://github.com/symfony/deprecation-contracts.git",
    236                 "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918"
    237             },
    238             "dist": {
    239                 "type": "zip",
    240                 "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/605389f2a7e5625f273b53960dc46aeaf9c62918",
    241                 "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918",
    242                 "shasum": ""
    243             },
    244             "require": {
    245                 "php": ">=7.1"
    246             },
    247             "time": "2024-09-25T14:11:13+00:00",
     288                "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6"
     289            },
     290            "dist": {
     291                "type": "zip",
     292                "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6",
     293                "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6",
     294                "shasum": ""
     295            },
     296            "require": {
     297                "php": ">=8.1"
     298            },
     299            "time": "2024-09-25T14:20:29+00:00",
    248300            "type": "library",
    249301            "extra": {
     
    253305                },
    254306                "branch-alias": {
    255                     "dev-main": "2.5-dev"
     307                    "dev-main": "3.5-dev"
    256308                }
    257309            },
     
    279331            "homepage": "https://symfony.com",
    280332            "support": {
    281                 "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.4"
     333                "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.1"
    282334            },
    283335            "funding": [
  • fakerpress/tags/0.8.0/vendor-prefixed/composer/platform_check.php

    r3296016 r3297704  
    55$issues = array();
    66
    7 if (!(PHP_VERSION_ID >= 70400)) {
    8     $issues[] = 'Your Composer dependencies require a PHP version ">= 7.4.0". You are running ' . PHP_VERSION . '.';
     7if (!(PHP_VERSION_ID >= 80100)) {
     8    $issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.';
    99}
    1010
  • fakerpress/tags/0.8.0/vendor-prefixed/symfony/deprecation-contracts/function.php

    r3296016 r3297704  
    2121     * @author Nicolas Grekas <p@tchwork.com>
    2222     */
    23     function fakerpress_thirdparty_trigger_deprecation(string $package, string $version, string $message, ...$args): void
     23    function fakerpress_thirdparty_trigger_deprecation(string $package, string $version, string $message, mixed ...$args): void
    2424    {
    2525        @trigger_error(($package || $version ? "Since $package $version: " : '').($args ? vsprintf($message, $args) : $message), \E_USER_DEPRECATED);
  • fakerpress/tags/0.8.0/vendor/autoload.php

    r3296016 r3297704  
    2020require_once __DIR__ . '/composer/autoload_real.php';
    2121
    22 return ComposerAutoloaderInit00ff3ad6aa458efbb11ddd65e622e447::getLoader();
     22return ComposerAutoloaderInit50f12ce0c9f654811ab62a438ee63247::getLoader();
  • fakerpress/tags/0.8.0/vendor/composer/autoload_aliases.php

    r3296016 r3297704  
    16091609      include "data://text/plain;base64," . base64_encode($includeFile);
    16101610      break;
    1611     case 'Cake\\Chronos\\MutableDate':
    1612       class_alias(\FakerPress\ThirdParty\Cake\Chronos\MutableDate::class, \Cake\Chronos\MutableDate::class);
    1613       break;
    1614     case 'Cake\\Chronos\\ChronosInterval':
    1615       class_alias(\FakerPress\ThirdParty\Cake\Chronos\ChronosInterval::class, \Cake\Chronos\ChronosInterval::class);
    1616       break;
    1617     case 'Cake\\Chronos\\MutableDateTime':
    1618       class_alias(\FakerPress\ThirdParty\Cake\Chronos\MutableDateTime::class, \Cake\Chronos\MutableDateTime::class);
     1611    case 'Cake\\Chronos\\ClockFactory':
     1612      class_alias(\FakerPress\ThirdParty\Cake\Chronos\ClockFactory::class, \Cake\Chronos\ClockFactory::class);
    16191613      break;
    16201614    case 'Cake\\Chronos\\Chronos':
    16211615      class_alias(\FakerPress\ThirdParty\Cake\Chronos\Chronos::class, \Cake\Chronos\Chronos::class);
    16221616      break;
    1623     case 'Cake\\Chronos\\ChronosInterface':
    1624       $includeFile = '<?php namespace Cake\Chronos; interface ChronosInterface extends \FakerPress\ThirdParty\Cake\Chronos\ChronosInterface {};';
    1625       include "data://text/plain;base64," . base64_encode($includeFile);
     1617    case 'Cake\\Chronos\\ChronosTime':
     1618      class_alias(\FakerPress\ThirdParty\Cake\Chronos\ChronosTime::class, \Cake\Chronos\ChronosTime::class);
    16261619      break;
    16271620    case 'Cake\\Chronos\\Translator':
    16281621      class_alias(\FakerPress\ThirdParty\Cake\Chronos\Translator::class, \Cake\Chronos\Translator::class);
    16291622      break;
    1630     case 'Cake\\Chronos\\Traits\\MagicPropertyTrait':
    1631       $includeFile = '<?php namespace Cake\Chronos\Traits; trait MagicPropertyTrait { use \FakerPress\ThirdParty\Cake\Chronos\Traits\MagicPropertyTrait };';
    1632       include "data://text/plain;base64," . base64_encode($includeFile);
    1633       break;
    1634     case 'Cake\\Chronos\\Traits\\ModifierTrait':
    1635       $includeFile = '<?php namespace Cake\Chronos\Traits; trait ModifierTrait { use \FakerPress\ThirdParty\Cake\Chronos\Traits\ModifierTrait };';
    1636       include "data://text/plain;base64," . base64_encode($includeFile);
    1637       break;
    1638     case 'Cake\\Chronos\\Traits\\FrozenTimeTrait':
    1639       $includeFile = '<?php namespace Cake\Chronos\Traits; trait FrozenTimeTrait { use \FakerPress\ThirdParty\Cake\Chronos\Traits\FrozenTimeTrait };';
    1640       include "data://text/plain;base64," . base64_encode($includeFile);
    1641       break;
    1642     case 'Cake\\Chronos\\Traits\\RelativeKeywordTrait':
    1643       $includeFile = '<?php namespace Cake\Chronos\Traits; trait RelativeKeywordTrait { use \FakerPress\ThirdParty\Cake\Chronos\Traits\RelativeKeywordTrait };';
    1644       include "data://text/plain;base64," . base64_encode($includeFile);
    1645       break;
    1646     case 'Cake\\Chronos\\Traits\\FactoryTrait':
    1647       $includeFile = '<?php namespace Cake\Chronos\Traits; trait FactoryTrait { use \FakerPress\ThirdParty\Cake\Chronos\Traits\FactoryTrait };';
    1648       include "data://text/plain;base64," . base64_encode($includeFile);
    1649       break;
    1650     case 'Cake\\Chronos\\Traits\\TestingAidTrait':
    1651       $includeFile = '<?php namespace Cake\Chronos\Traits; trait TestingAidTrait { use \FakerPress\ThirdParty\Cake\Chronos\Traits\TestingAidTrait };';
    1652       include "data://text/plain;base64," . base64_encode($includeFile);
    1653       break;
    1654     case 'Cake\\Chronos\\Traits\\CopyTrait':
    1655       $includeFile = '<?php namespace Cake\Chronos\Traits; trait CopyTrait { use \FakerPress\ThirdParty\Cake\Chronos\Traits\CopyTrait };';
    1656       include "data://text/plain;base64," . base64_encode($includeFile);
    1657       break;
    1658     case 'Cake\\Chronos\\Traits\\DifferenceTrait':
    1659       $includeFile = '<?php namespace Cake\Chronos\Traits; trait DifferenceTrait { use \FakerPress\ThirdParty\Cake\Chronos\Traits\DifferenceTrait };';
    1660       include "data://text/plain;base64," . base64_encode($includeFile);
    1661       break;
    1662     case 'Cake\\Chronos\\Traits\\ComparisonTrait':
    1663       $includeFile = '<?php namespace Cake\Chronos\Traits; trait ComparisonTrait { use \FakerPress\ThirdParty\Cake\Chronos\Traits\ComparisonTrait };';
    1664       include "data://text/plain;base64," . base64_encode($includeFile);
    1665       break;
    1666     case 'Cake\\Chronos\\Traits\\TimezoneTrait':
    1667       $includeFile = '<?php namespace Cake\Chronos\Traits; trait TimezoneTrait { use \FakerPress\ThirdParty\Cake\Chronos\Traits\TimezoneTrait };';
    1668       include "data://text/plain;base64," . base64_encode($includeFile);
    1669       break;
    1670     case 'Cake\\Chronos\\Traits\\FormattingTrait':
    1671       $includeFile = '<?php namespace Cake\Chronos\Traits; trait FormattingTrait { use \FakerPress\ThirdParty\Cake\Chronos\Traits\FormattingTrait };';
     1623    case 'Cake\\Chronos\\FormattingTrait':
     1624      $includeFile = '<?php namespace Cake\Chronos; trait FormattingTrait { use \FakerPress\ThirdParty\Cake\Chronos\FormattingTrait };';
     1625      include "data://text/plain;base64," . base64_encode($includeFile);
     1626      break;
     1627    case 'Psr\\Clock\\ClockInterface':
     1628      $includeFile = '<?php namespace Psr\Clock; interface ClockInterface extends \FakerPress\ThirdParty\Psr\Clock\ClockInterface {};';
    16721629      include "data://text/plain;base64," . base64_encode($includeFile);
    16731630      break;
  • fakerpress/tags/0.8.0/vendor/composer/autoload_real.php

    r3296016 r3297704  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit00ff3ad6aa458efbb11ddd65e622e447
     5class ComposerAutoloaderInit50f12ce0c9f654811ab62a438ee63247
    66{
    77    private static $loader;
     
    2323        }
    2424
    25         spl_autoload_register(array('ComposerAutoloaderInit00ff3ad6aa458efbb11ddd65e622e447', 'loadClassLoader'), true, true);
     25        spl_autoload_register(array('ComposerAutoloaderInit50f12ce0c9f654811ab62a438ee63247', 'loadClassLoader'), true, true);
    2626        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    27         spl_autoload_unregister(array('ComposerAutoloaderInit00ff3ad6aa458efbb11ddd65e622e447', 'loadClassLoader'));
     27        spl_autoload_unregister(array('ComposerAutoloaderInit50f12ce0c9f654811ab62a438ee63247', 'loadClassLoader'));
    2828
    2929        require __DIR__ . '/autoload_static.php';
    30         call_user_func(\Composer\Autoload\ComposerStaticInit00ff3ad6aa458efbb11ddd65e622e447::getInitializer($loader));
     30        call_user_func(\Composer\Autoload\ComposerStaticInit50f12ce0c9f654811ab62a438ee63247::getInitializer($loader));
    3131
    3232        $loader->register(true);
    3333
    34         $filesToLoad = \Composer\Autoload\ComposerStaticInit00ff3ad6aa458efbb11ddd65e622e447::$files;
     34        $filesToLoad = \Composer\Autoload\ComposerStaticInit50f12ce0c9f654811ab62a438ee63247::$files;
    3535        $requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
    3636            if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • fakerpress/tags/0.8.0/vendor/composer/autoload_static.php

    r3296016 r3297704  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit00ff3ad6aa458efbb11ddd65e622e447
     7class ComposerStaticInit50f12ce0c9f654811ab62a438ee63247
    88{
    99    public static $files = array (
     
    9595    {
    9696        return \Closure::bind(function () use ($loader) {
    97             $loader->prefixLengthsPsr4 = ComposerStaticInit00ff3ad6aa458efbb11ddd65e622e447::$prefixLengthsPsr4;
    98             $loader->prefixDirsPsr4 = ComposerStaticInit00ff3ad6aa458efbb11ddd65e622e447::$prefixDirsPsr4;
    99             $loader->classMap = ComposerStaticInit00ff3ad6aa458efbb11ddd65e622e447::$classMap;
     97            $loader->prefixLengthsPsr4 = ComposerStaticInit50f12ce0c9f654811ab62a438ee63247::$prefixLengthsPsr4;
     98            $loader->prefixDirsPsr4 = ComposerStaticInit50f12ce0c9f654811ab62a438ee63247::$prefixDirsPsr4;
     99            $loader->classMap = ComposerStaticInit50f12ce0c9f654811ab62a438ee63247::$classMap;
    100100
    101101        }, null, ClassLoader::class);
  • fakerpress/tags/0.8.0/vendor/composer/installed.json

    r3296016 r3297704  
    33        {
    44            "name": "cakephp/chronos",
    5             "version": "2.4.5",
    6             "version_normalized": "2.4.5.0",
     5            "version": "3.1.0",
     6            "version_normalized": "3.1.0.0",
    77            "source": {
    88                "type": "git",
    99                "url": "https://github.com/cakephp/chronos.git",
    10                 "reference": "b0321ab7658af9e7abcb3dd876f226e6f3dbb81f"
    11             },
    12             "dist": {
    13                 "type": "zip",
    14                 "url": "https://api.github.com/repos/cakephp/chronos/zipball/b0321ab7658af9e7abcb3dd876f226e6f3dbb81f",
    15                 "reference": "b0321ab7658af9e7abcb3dd876f226e6f3dbb81f",
    16                 "shasum": ""
    17             },
    18             "require": {
    19                 "php": ">=7.2"
     10                "reference": "786d69e1ee4b735765cbdb5521b9603e9b98d650"
     11            },
     12            "dist": {
     13                "type": "zip",
     14                "url": "https://api.github.com/repos/cakephp/chronos/zipball/786d69e1ee4b735765cbdb5521b9603e9b98d650",
     15                "reference": "786d69e1ee4b735765cbdb5521b9603e9b98d650",
     16                "shasum": ""
     17            },
     18            "require": {
     19                "php": ">=8.1",
     20                "psr/clock": "^1.0"
     21            },
     22            "provide": {
     23                "psr/clock-implementation": "1.0"
    2024            },
    2125            "require-dev": {
    22                 "cakephp/cakephp-codesniffer": "^4.5",
    23                 "phpunit/phpunit": "^8.0 || ^9.0"
    24             },
    25             "time": "2024-07-30T22:26:11+00:00",
    26             "type": "library",
    27             "installation-source": "dist",
    28             "autoload": {
    29                 "files": [
    30                     "src/carbon_compat.php"
    31                 ],
     26                "cakephp/cakephp-codesniffer": "^5.0",
     27                "phpunit/phpunit": "^10.1.0 || ^11.1.3"
     28            },
     29            "time": "2024-07-18T03:18:04+00:00",
     30            "type": "library",
     31            "installation-source": "dist",
     32            "autoload": {
    3233                "psr-4": {
    3334                    "FakerPress\\ThirdParty\\Cake\\Chronos\\": "src/"
     
    175176            },
    176177            "install-path": "../../vendor-prefixed/lucatume/di52/"
     178        },
     179        {
     180            "name": "psr/clock",
     181            "version": "1.0.0",
     182            "version_normalized": "1.0.0.0",
     183            "source": {
     184                "type": "git",
     185                "url": "https://github.com/php-fig/clock.git",
     186                "reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d"
     187            },
     188            "dist": {
     189                "type": "zip",
     190                "url": "https://api.github.com/repos/php-fig/clock/zipball/e41a24703d4560fd0acb709162f73b8adfc3aa0d",
     191                "reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d",
     192                "shasum": ""
     193            },
     194            "require": {
     195                "php": "^7.0 || ^8.0"
     196            },
     197            "time": "2022-11-25T14:36:26+00:00",
     198            "type": "library",
     199            "installation-source": "dist",
     200            "autoload": {
     201                "psr-4": {
     202                    "FakerPress\\ThirdParty\\Psr\\Clock\\": "src/"
     203                }
     204            },
     205            "notification-url": "https://packagist.org/downloads/",
     206            "license": [
     207                "MIT"
     208            ],
     209            "authors": [
     210                {
     211                    "name": "PHP-FIG",
     212                    "homepage": "https://www.php-fig.org/"
     213                }
     214            ],
     215            "description": "Common interface for reading the clock.",
     216            "homepage": "https://github.com/php-fig/clock",
     217            "keywords": [
     218                "clock",
     219                "now",
     220                "psr",
     221                "psr-20",
     222                "time"
     223            ],
     224            "support": {
     225                "issues": "https://github.com/php-fig/clock/issues",
     226                "source": "https://github.com/php-fig/clock/tree/1.0.0"
     227            },
     228            "install-path": "../../vendor-prefixed/psr/clock/"
    177229        },
    178230        {
     
    229281        {
    230282            "name": "symfony/deprecation-contracts",
    231             "version": "v2.5.4",
    232             "version_normalized": "2.5.4.0",
     283            "version": "v3.5.1",
     284            "version_normalized": "3.5.1.0",
    233285            "source": {
    234286                "type": "git",
    235287                "url": "https://github.com/symfony/deprecation-contracts.git",
    236                 "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918"
    237             },
    238             "dist": {
    239                 "type": "zip",
    240                 "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/605389f2a7e5625f273b53960dc46aeaf9c62918",
    241                 "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918",
    242                 "shasum": ""
    243             },
    244             "require": {
    245                 "php": ">=7.1"
    246             },
    247             "time": "2024-09-25T14:11:13+00:00",
     288                "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6"
     289            },
     290            "dist": {
     291                "type": "zip",
     292                "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6",
     293                "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6",
     294                "shasum": ""
     295            },
     296            "require": {
     297                "php": ">=8.1"
     298            },
     299            "time": "2024-09-25T14:20:29+00:00",
    248300            "type": "library",
    249301            "extra": {
     
    253305                },
    254306                "branch-alias": {
    255                     "dev-main": "2.5-dev"
     307                    "dev-main": "3.5-dev"
    256308                }
    257309            },
     
    279331            "homepage": "https://symfony.com",
    280332            "support": {
    281                 "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.4"
     333                "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.1"
    282334            },
    283335            "funding": [
  • fakerpress/tags/0.8.0/vendor/composer/installed.php

    r3296016 r3297704  
    22    'root' => array(
    33        'name' => 'bordoni/fakerpress',
    4         'pretty_version' => '0.7.2',
    5         'version' => '0.7.2.0',
    6         'reference' => 'b4a61a492a19b879b8a7e3c70ea1ff51b990f58b',
     4        'pretty_version' => 'dev-main',
     5        'version' => 'dev-main',
     6        'reference' => 'c240003f80bdfbdc72134c81c02d108978dae386',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    1212    'versions' => array(
    1313        'bordoni/fakerpress' => array(
    14             'pretty_version' => '0.7.2',
    15             'version' => '0.7.2.0',
    16             'reference' => 'b4a61a492a19b879b8a7e3c70ea1ff51b990f58b',
     14            'pretty_version' => 'dev-main',
     15            'version' => 'dev-main',
     16            'reference' => 'c240003f80bdfbdc72134c81c02d108978dae386',
    1717            'type' => 'wordpress-plugin',
    1818            'install_path' => __DIR__ . '/../../',
     
    2121        ),
    2222        'cakephp/chronos' => array(
    23             'pretty_version' => '2.4.5',
    24             'version' => '2.4.5.0',
    25             'reference' => 'b0321ab7658af9e7abcb3dd876f226e6f3dbb81f',
     23            'pretty_version' => '3.1.0',
     24            'version' => '3.1.0.0',
     25            'reference' => '786d69e1ee4b735765cbdb5521b9603e9b98d650',
    2626            'type' => 'library',
    2727            'install_path' => __DIR__ . '/../cakephp/chronos',
     
    4747            'dev_requirement' => false,
    4848        ),
     49        'psr/clock' => array(
     50            'pretty_version' => '1.0.0',
     51            'version' => '1.0.0.0',
     52            'reference' => 'e41a24703d4560fd0acb709162f73b8adfc3aa0d',
     53            'type' => 'library',
     54            'install_path' => __DIR__ . '/../psr/clock',
     55            'aliases' => array(),
     56            'dev_requirement' => false,
     57        ),
     58        'psr/clock-implementation' => array(
     59            'dev_requirement' => false,
     60            'provided' => array(
     61                0 => '1.0',
     62            ),
     63        ),
    4964        'psr/container' => array(
    5065            'pretty_version' => '1.1.2',
     
    5772        ),
    5873        'symfony/deprecation-contracts' => array(
    59             'pretty_version' => 'v2.5.4',
    60             'version' => '2.5.4.0',
    61             'reference' => '605389f2a7e5625f273b53960dc46aeaf9c62918',
     74            'pretty_version' => 'v3.5.1',
     75            'version' => '3.5.1.0',
     76            'reference' => '74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6',
    6277            'type' => 'library',
    6378            'install_path' => __DIR__ . '/../symfony/deprecation-contracts',
Note: See TracChangeset for help on using the changeset viewer.