diff --git a/composer.json b/composer.json
index 66c4d872b..e061e420d 100644
--- a/composer.json
+++ b/composer.json
@@ -6,7 +6,7 @@
"cmixin/business-time": "dev-master",
"cmixin/season": "dev-main",
"kylekatarnls/carbonite": "dev-master",
- "nesbot/carbon": "dev-master as 3.8.1"
+ "nesbot/carbon": "dev-master as 3.8.2"
},
"scripts": {
"check": "@php tools/check.php",
diff --git a/docs/sponsors/slotozilla.png b/docs/sponsors/slotozilla.png
new file mode 100644
index 000000000..16eb92244
Binary files /dev/null and b/docs/sponsors/slotozilla.png differ
diff --git a/tidelift-brand.png b/docs/sponsors/tidelift-brand.png
similarity index 100%
rename from tidelift-brand.png
rename to docs/sponsors/tidelift-brand.png
diff --git a/tidelift.png b/docs/sponsors/tidelift.png
similarity index 100%
rename from tidelift.png
rename to docs/sponsors/tidelift.png
diff --git a/index.html b/index.html
index 825246b1b..845b240cc 100644
--- a/index.html
+++ b/index.html
@@ -153,7 +153,7 @@
Installing
{
"require": {
- "nesbot/carbon": "^3.8.1"
+ "nesbot/carbon": "^3.8.2"
}
}
@@ -216,26 +216,24 @@
@@ -246,8 +244,19 @@ Backers
+
+
+
+
+
+
+
+
+
+
+
@@ -276,24 +285,24 @@ Backers
-
-
-
+
+
+
-
+
diff --git a/tools/generate.php b/tools/generate.php
index 3867de9fe..173431fc5 100644
--- a/tools/generate.php
+++ b/tools/generate.php
@@ -267,8 +267,8 @@ function historyLine($event, $version, $ref): string
function getAllBackers(): array
{
- $data = json_decode(file_get_contents('https://opencollective.com/carbon/members/all.json'), true);
- $data[] = [
+ $members = json_decode(file_get_contents('https://opencollective.com/carbon/members/all.json'), true);
+ $members[] = [
'MemberId' => 1,
'createdAt' => '2019-01-01 02:00',
'type' => 'ORGANIZATION',
@@ -282,9 +282,26 @@ function getAllBackers(): array
'profile' => 'https://tidelift.com/',
'name' => 'Tidelift',
'description' => 'Get professional support for Carbon',
- 'image' => '/tidelift-brand.png',
+ 'image' => '/docs/sponsors/tidelift-brand.png',
'website' => 'https://tidelift.com/subscription/pkg/packagist-nesbot-carbon?utm_source=packagist-nesbot-carbon&utm_medium=referral&utm_campaign=docs',
];
+ $members[] = [
+ 'MemberId' => 2,
+ 'createdAt' => '2024-11-07 02:00',
+ 'type' => 'ORGANIZATION',
+ 'role' => 'BACKER',
+ 'tier' => 'backer+ yearly',
+ 'isActive' => true,
+ 'totalAmountDonated' => 170,
+ 'currency' => 'USD',
+ 'lastTransactionAt' => '2024-11-07 02:00',
+ 'lastTransactionAmount' => 170,
+ 'profile' => 'https://www.slotozilla.com/nz/free-spins',
+ 'name' => 'Slotozilla',
+ 'description' => 'Slotozilla website',
+ 'image' => '/docs/sponsors/slotozilla.png',
+ 'website' => 'https://www.slotozilla.com/nz/free-spins',
+ ];
return array_map(static function (array $member) {
$createdAt = CarbonImmutable::parse($member['createdAt']);
@@ -296,21 +313,30 @@ function getAllBackers(): array
->modify($lastTransactionAt->format('H:i:s.u'));
}
- $monthlyContribution = (float) ($member['totalAmountDonated'] / ceil($createdAt->floatDiffInMonths()));
+ $isYearly = str_contains(strtolower($member['tier'] ?? ''), 'yearly');
+ $monthlyContribution = (float) ($isYearly && $lastTransactionAt > CarbonImmutable::parse('-1 year')
+ ? ($member['lastTransactionAmount'] / 11.2) // 11.2 instead of 12 to include the discount for yearly subscription
+ : ($member['totalAmountDonated'] / ceil($createdAt->floatDiffInMonths()))
+ );
- if (
- $lastTransactionAt->isAfter('last month') &&
- $member['lastTransactionAmount'] > $monthlyContribution
- ) {
- $monthlyContribution = (float) $member['lastTransactionAmount'];
- }
+ if (!$isYearly) {
+ if (
+ $lastTransactionAt->isAfter('last month') &&
+ $member['lastTransactionAmount'] > $monthlyContribution
+ ) {
+ $monthlyContribution = (float) $member['lastTransactionAmount'];
+ }
- if ($lastTransactionAt->isBefore('-75 days')) {
- $days = min(120, $lastTransactionAt->diffInDays('now') - 70);
- $monthlyContribution *= 1 - $days / 240;
+ if ($lastTransactionAt->isBefore('-75 days')) {
+ $days = min(120, $lastTransactionAt->diffInDays('now') - 70);
+ $monthlyContribution *= 1 - $days / 240;
+ }
}
- $yearlyContribution = (float) ($member['totalAmountDonated'] / max(1, $createdAt->floatDiffInYears()));
+ $yearlyContribution = (float) ($isYearly
+ ? (12 * $monthlyContribution)
+ : ($member['totalAmountDonated'] / max(1, $createdAt->floatDiffInYears()))
+ );
$status = null;
$rank = 0;
@@ -338,7 +364,7 @@ function getAllBackers(): array
'monthlyContribution' => $monthlyContribution,
'yearlyContribution' => $yearlyContribution,
]);
- }, $data);
+ }, $members);
}
function getOpenCollective(string $status): string
@@ -431,7 +457,7 @@ function genHtml(string $page, string $out, string $jumbotron = ''): void
$html = str_replace('#{menu}', $menu, $html);
$html = str_replace('#{scripts}', $scripts, $html);
$html = str_replace('#{openCollectiveSponsors}', getOpenCollective('sponsor'), $html);
- $html = str_replace('#{openCollectiveBackers}', getOpenCollective('backer'), $html);
+ $html = str_replace('#{openCollectiveBackers}', getOpenCollective('backerPlus').getOpenCollective('backer'), $html);
$html = str_replace('#{openCollectiveHelpers}', getOpenCollective('helper'), $html);
writeFileAtPath($out, cleanupHtml($html));