Skip to content

Commit 7cddd44

Browse files
committed
Update supported versions
1 parent b74ab3e commit 7cddd44

File tree

5 files changed

+53
-27
lines changed

5 files changed

+53
-27
lines changed

.github/workflows/CI.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
php-versions: ['8.2', '8.3', '8.4']
10+
php-versions: ['8.4', '8.5']
1111
fail-fast: false
1212
steps:
13-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@v5
1414
- uses: shivammathur/setup-php@v2
1515
with:
1616
php-version: ${{ matrix.php-versions }}
17-
extensions: gd, mbstring, pcov, zip
17+
extensions: gd, mbstring, zip
1818
ini-values: max_execution_time=600, memory_limit=-1
1919
tools: composer:v2
20-
coverage: pcov
20+
coverage: xdebug
2121
env:
2222
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2323

@@ -54,7 +54,7 @@ jobs:
5454
run: |
5555
composer update --prefer-lowest
5656
vendor/bin/unit-test
57-
vendor/bin/functional-test 5.4
57+
vendor/bin/functional-test 6.4
5858
5959
- name: Archive logs
6060
if: ${{ failure() }}
@@ -64,7 +64,7 @@ jobs:
6464
path: vendor/endroid/quality/application/var/log
6565

6666
- name: Archive code coverage results
67-
uses: actions/upload-artifact@v4
67+
uses: actions/upload-artifact@v5
6868
with:
6969
name: coverage-php-${{ matrix.php-versions }}
7070
path: tests/coverage

.install/symfony/config/packages/endroid_teleporter.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2024 (c) Jeroen van den Enden
1+
Copyright 2025 (c) Jeroen van den Enden
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
}
1313
],
1414
"require": {
15-
"php": "^8.2",
15+
"php": "^8.4",
1616
"ext-fileinfo": "*",
17-
"cocur/slugify": "^4.0",
18-
"endroid/installer": "^1.3.2",
19-
"symfony/console": "^5.4||^6.4||^7.0",
20-
"symfony/filesystem": "^5.4||^6.4||^7.0",
21-
"symfony/finder": "^5.4||^6.4||^7.0",
17+
"ext-iconv": "*",
18+
"ext-mbstring": "*",
19+
"symfony/console": "^6.4||^7.4||^8.0",
20+
"symfony/filesystem": "^6.4||^7.4||^8.0",
21+
"symfony/finder": "^6.4||^7.4||^8.0",
2222
"twig/twig": "^3.0"
2323
},
2424
"require-dev": {

src/Teleporter.php

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Endroid\Teleporter;
66

7-
use Cocur\Slugify\Slugify;
87
use Symfony\Component\Filesystem\Filesystem;
98
use Symfony\Component\Finder\Finder;
109
use Symfony\Component\Finder\SplFileInfo;
@@ -34,7 +33,6 @@ public function teleport(string $sourcePath, string $targetPath, array $selectio
3433
$finder = new Finder();
3534
$finder->ignoreDotFiles(false);
3635

37-
/** @var SplFileInfo[] $files */
3836
$files = $finder
3937
->files()
4038
->notName('.teleport')
@@ -74,7 +72,6 @@ private function determineSkipFolders(string $sourcePath, array $selections): ar
7472
$finder = new Finder();
7573
$finder->ignoreDotFiles(false);
7674

77-
/** @var SplFileInfo[] $files */
7875
$files = $finder->files()->name('.teleport')->in($sourcePath);
7976

8077
foreach ($files as $file) {
@@ -134,9 +131,7 @@ private function createRenderer(string $sourcePath): Environment
134131

135132
// Add slugify filter
136133
$twig->addFilter(new TwigFilter('slug', function (string $contents) {
137-
$slugify = new Slugify();
138-
139-
return $slugify->slugify($contents);
134+
return $this->slugify($contents);
140135
}));
141136

142137
// Make sure regular Twig files are not affected
@@ -170,4 +165,43 @@ private function createRendererContext(array $selections, array $replaces): arra
170165

171166
return $context;
172167
}
168+
169+
private function slugify(string $text): string
170+
{
171+
// Convert to lowercase
172+
$text = mb_strtolower($text, 'UTF-8');
173+
174+
// Replace non-letter or digits with hyphens
175+
$text = preg_replace('~[^\pL\d]+~u', '-', $text);
176+
177+
// Handle null case from preg_replace
178+
if (null === $text) {
179+
return '';
180+
}
181+
182+
// Transliterate
183+
$converted = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $text);
184+
185+
// Handle false case from iconv
186+
if (false === $converted) {
187+
return '';
188+
}
189+
190+
// Remove non-alphanumeric characters
191+
$text = preg_replace('~[^-\w]+~', '', $converted);
192+
193+
// Handle null case from preg_replace
194+
if (null === $text) {
195+
return '';
196+
}
197+
198+
// Trim hyphens from ends
199+
$text = trim($text, '-');
200+
201+
// Remove duplicate hyphens
202+
$text = preg_replace('~-+~', '-', $text);
203+
204+
// Handle null case and return empty string if result is empty
205+
return $text ?? '';
206+
}
173207
}

0 commit comments

Comments
 (0)