-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9183f16
commit b4311b0
Showing
19 changed files
with
1,097 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ package-lock.json | |
|
||
# Etc | ||
.DS_Store | ||
bin/*.pid | ||
bin/*.log | ||
|
||
# PHPUnit (PHP) | ||
.phpunit.result.cache | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
/** | ||
* Crazy Migration | ||
* | ||
* Command for controle migration | ||
* | ||
* PHP version 8.1.2 | ||
* | ||
* @package kzarshenas/crazyphp | ||
* @author kekefreedog <kevin.zarshenas@gmail.com> | ||
* @copyright 2022-2024 Kévin Zarshenas | ||
*/ | ||
require getcwd().'/vendor/autoload.php' ; | ||
|
||
/** | ||
* Dependances | ||
*/ | ||
use CrazyPHP\Model\Env; | ||
use CrazyPHP\Cli\Core; | ||
|
||
# Define env constants | ||
Env::set([ | ||
"app_root" => getcwd(), | ||
"crazyphp_root" => getcwd()."/vendor/kzarshenas/crazyphp", | ||
]); | ||
|
||
// Execute core | ||
(new Core())->run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Handlebars Strings Helpers | ||
* | ||
* @source https://github.com/helpers/handlebars-helpers | ||
* | ||
* @package kzarshenas/crazyphp | ||
* @author kekefreedog <kevin.zarshenas@gmail.com> | ||
* @copyright 2022-2024 Kévin Zarshenas | ||
*/ | ||
|
||
/** | ||
* Date To Local Format | ||
* | ||
* Return date to local format Vendredi 13 Janvier | ||
* | ||
* @param input | ||
* @param local () | ||
* | ||
* @return string | ||
*/ | ||
module.exports = function(input, locale, options) { | ||
|
||
// Set result | ||
let result = input; | ||
|
||
// Check input | ||
if(typeof input === "string" && input && typeof locale === "string" && locale){ | ||
|
||
// convert to date | ||
const date = new Date(input); | ||
|
||
// Invalid date fallback | ||
if(!isNaN(date)){ | ||
|
||
// Set options | ||
const options = { weekday: 'long', day: 'numeric', month: 'long' }; | ||
|
||
// Set result | ||
result = date.toLocaleDateString(locale, options); | ||
|
||
} | ||
|
||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Handlebars Array Helpers | ||
* | ||
* @source https://github.com/helpers/handlebars-helpers | ||
* | ||
* @package kzarshenas/crazyphp | ||
* @author kekefreedog <kevin.zarshenas@gmail.com> | ||
* @copyright 2022-2024 Kévin Zarshenas | ||
*/ | ||
|
||
/** | ||
* Days of month | ||
* | ||
* Handlebars helper to get all days of a given month and year | ||
* | ||
* @param {number} year - The year (e.g., 2025). | ||
* @param {number} month - The month (1 for January, 12 for December). | ||
* @param {object} options - Handlebars options object. | ||
* @returns {string} - Rendered HTML of all dates. | ||
*/ | ||
module.exports = function(year, month, options) { | ||
|
||
// Check year | ||
year = Number.isInteger(year) && year > 0 | ||
? year | ||
: now.getFullYear() | ||
; | ||
|
||
// Check month | ||
month = Number.isInteger(month) && month >= 1 && month <= 12 | ||
? month | ||
: now.getMonth() + 1 | ||
; | ||
|
||
// Adjust for JavaScript's 0-based months | ||
const adjustedMonth = month - 1; | ||
|
||
// Get number of days in the month | ||
const daysInMonth = new Date(year, month, 0).getDate(); | ||
|
||
// Get days | ||
const days = []; | ||
|
||
// Iteration days in month | ||
for(let day = 1; day <= daysInMonth; day++){ | ||
|
||
// Set date | ||
const date = new Date(year, adjustedMonth, day); | ||
|
||
// Set formated date | ||
const formattedDate = date.toISOString().split('T')[0]; | ||
|
||
// Push in result | ||
days.push(formattedDate); | ||
} | ||
|
||
// Return days | ||
return days; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Handlebars Comparaison Helpers | ||
* | ||
* @source https://github.com/helpers/handlebars-helpers | ||
* | ||
* @package kzarshenas/crazyphp | ||
* @author kekefreedog <kevin.zarshenas@gmail.com> | ||
* @copyright 2022-2024 Kévin Zarshenas | ||
*/ | ||
|
||
/** | ||
* Is Current Day | ||
* | ||
* Returns true if value (2025-01-05) is the current day | ||
* | ||
* @param input like 2025-01-12 | ||
* @return boolean | ||
*/ | ||
module.exports = function(input, options) { | ||
|
||
// Return result | ||
return typeof input === "string" && input && inputDate === (new Date().toISOString().split('T')[0]) | ||
? options.fn(this) | ||
: options.inverse(this) | ||
; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Handlebars Comparaison Helpers | ||
* | ||
* @source https://github.com/helpers/handlebars-helpers | ||
* | ||
* @package kzarshenas/crazyphp | ||
* @author kekefreedog <kevin.zarshenas@gmail.com> | ||
* @copyright 2022-2024 Kévin Zarshenas | ||
*/ | ||
|
||
/** | ||
* Is Weekend | ||
* | ||
* Returns true if value (2025-01-05) is the weekend | ||
* | ||
* @param input like 2025-01-12 | ||
* @return boolean | ||
*/ | ||
module.exports = function(input, options) { | ||
|
||
// Set result | ||
let result = false; | ||
|
||
// Check date | ||
if(typeof input === "string" && input){ | ||
|
||
// Set date | ||
const date = new Date(inputDate); | ||
|
||
// Get day in week 0 = Sunday, 6 = Saturday | ||
const day = date.getDay(); | ||
|
||
// Check if weekend | ||
if(day === 0 || day === 6) | ||
|
||
// Set result | ||
result = true; | ||
|
||
} | ||
|
||
// Return result | ||
return result | ||
? options.fn(this) | ||
: options.inverse(this) | ||
; | ||
|
||
}; |
Oops, something went wrong.