Skip to content

Commit 209cf73

Browse files
committed
Upgrade depends
1 parent d65d099 commit 209cf73

5 files changed

Lines changed: 22 additions & 43 deletions

File tree

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnError="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnError="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/13.1/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
33
<testsuites>
44
<testsuite name="Laravel Inky Test Suite">
55
<directory suffix="Test.php">./tests</directory>

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Allows you to use Foundation's [Inky](http://foundation.zurb.com/emails/docs/inky.html) email templates nicely in Laravel 6-11.
1+
Allows you to use Foundation's [Inky](http://foundation.zurb.com/emails/docs/inky.html) email templates nicely in Laravel 12-13. Requires PHP 8.4+.
22

33
Any views with a `.inky.php` extension will be compiled with both Inky and Blade, allowing you to use both templating engines seamlessly together. CSS is automatically inlined so styles work in email clients that don't support external stylesheets.
44

src/InkyCompiler.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,23 @@
55
use IncentFit\Inky\Inky;
66
use Illuminate\Filesystem\Filesystem;
77
use Illuminate\View\Compilers\Compiler;
8+
use Illuminate\View\Compilers\BladeCompiler;
89
use Illuminate\View\Compilers\CompilerInterface;
910

1011
class InkyCompiler extends Compiler implements CompilerInterface
1112
{
12-
protected $inky;
13+
protected Inky $inky;
1314

14-
protected $blade;
15+
protected ?string $path = null;
1516

16-
protected $path;
17-
18-
public function __construct(Compiler $blade, Filesystem $files, $cachePath)
17+
public function __construct(protected BladeCompiler $blade, Filesystem $files, string $cachePath)
1918
{
2019
parent::__construct($files, $cachePath);
2120

22-
$this->blade = $blade;
2321
$this->inky = new Inky;
2422
}
2523

26-
public function compile($path = null)
24+
public function compile($path = null): void
2725
{
2826
if ($path) {
2927
$this->setPath($path);
@@ -36,29 +34,29 @@ public function compile($path = null)
3634
}
3735
}
3836

39-
public function getPath()
37+
public function getPath(): ?string
4038
{
4139
return $this->path;
4240
}
4341

44-
public function setPath($path)
42+
public function setPath(string $path): static
4543
{
4644
$this->path = $path;
4745

4846
return $this;
4947
}
5048

51-
public function compileString($value)
49+
public function compileString(string $value): string
5250
{
5351
return $this->blade->compileString($this->inky->releaseTheKraken($value));
5452
}
5553

56-
public function getFiles()
54+
public function getFiles(): Filesystem
5755
{
5856
return $this->files;
5957
}
6058

61-
public function getBlade()
59+
public function getBlade(): BladeCompiler
6260
{
6361
return $this->blade;
6462
}

src/InkyCompilerEngine.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,15 @@
1111

1212
class InkyCompilerEngine extends CompilerEngine
1313
{
14-
protected $filesystem;
15-
16-
public function __construct(CompilerInterface $compiler, Filesystem $filesystem)
14+
public function __construct(CompilerInterface $compiler, protected Filesystem $filesystem)
1715
{
1816
parent::__construct($compiler);
19-
20-
$this->filesystem = $filesystem;
2117
}
2218

23-
public function get($inkyFilePath, array $data = [])
19+
public function get($inkyFilePath, array $data = []): string
2420
{
25-
// Compiles the inky template as if it were a regular blade file
2621
$html = parent::get($inkyFilePath, $data);
2722

28-
// remove css stylesheet links from email's HTML
2923
$crawler = new Crawler;
3024
$crawler->addHtmlContent($html);
3125
$cssLinks = $crawler->filter('link[rel=stylesheet]');
@@ -38,10 +32,9 @@ public function get($inkyFilePath, array $data = [])
3832

3933
$htmlWithoutLinks = $crawler->html();
4034

41-
// Combine all stylesheets into 1 string of CSS
42-
$combinedStyles = collect(config('inky.stylesheets'))->map(function ($path) {
43-
return $this->filesystem->get(base_path($path));
44-
})->implode("\n\n");
35+
$combinedStyles = collect(config('inky.stylesheets'))
36+
->map(fn ($path) => $this->filesystem->get(base_path($path)))
37+
->implode("\n\n");
4538

4639
$inliner = new CssToInlineStyles;
4740

@@ -51,7 +44,7 @@ public function get($inkyFilePath, array $data = [])
5144
);
5245
}
5346

54-
public function getFiles()
47+
public function getFiles(): Filesystem
5548
{
5649
return $this->filesystem;
5750
}

src/InkyServiceProvider.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@
66

77
class InkyServiceProvider extends ServiceProvider
88
{
9-
/**
10-
* Bootstrap the application services.
11-
*
12-
* @return void
13-
*/
14-
public function boot()
9+
public function boot(): void
1510
{
1611
$this->registerExtension();
1712

@@ -20,12 +15,7 @@ public function boot()
2015
]);
2116
}
2217

23-
/**
24-
* Register the application services.
25-
*
26-
* @return void
27-
*/
28-
public function register()
18+
public function register(): void
2919
{
3020
$app = $this->app;
3121
$resolver = $app['view.engine.resolver'];
@@ -36,12 +26,10 @@ public function register()
3626
return new InkyCompiler($app['blade.compiler'], $app['files'], $cache);
3727
});
3828

39-
$resolver->register('inky', function () use ($app) {
40-
return new InkyCompilerEngine($app['inky.compiler'], $app['files']);
41-
});
29+
$resolver->register('inky', fn () => new InkyCompilerEngine($app['inky.compiler'], $app['files']));
4230
}
4331

44-
protected function registerExtension()
32+
protected function registerExtension(): void
4533
{
4634
$this->app['view']->addExtension('inky.php', 'inky');
4735
}

0 commit comments

Comments
 (0)