• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Cecilapp / Cecil / 7142649554

08 Dec 2023 02:37PM UTC coverage: 83.0% (+0.5%) from 82.534%
7142649554

push

github

web-flow
8.x (#1676)

186 of 231 new or added lines in 31 files covered. (80.52%)

17 existing lines in 6 files now uncovered.

2861 of 3447 relevant lines covered (83.0%)

0.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.0
/src/Step/Optimize/Images.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of Cecil.
7
 *
8
 * Copyright (c) Arnaud Ligny <arnaud@ligny.fr>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13

14
namespace Cecil\Step\Optimize;
15

16
use Cecil\Assets\Image\Optimizer;
17

18
/**
19
 * Optimize image files.
20
 */
21
class Images extends AbstractOptimize
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function getName(): string
27
    {
28
        return 'Optimizing images';
1✔
29
    }
30

31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function init(array $options): void
35
    {
36
        $this->type = 'images';
1✔
37
        parent::init($options);
1✔
38
    }
39

40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function setProcessor(): void
44
    {
45
        $this->processor = Optimizer::create($this->config->get('assets.images.quality') ?? 75);
1✔
46
    }
47

48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function processFile(\Symfony\Component\Finder\SplFileInfo $file): string
52
    {
53
        try {
54
            $this->processor->optimize($file->getPathname());
1✔
NEW
55
        } catch (\Exception $e) {
×
NEW
56
            $this->builder->getLogger()->error(sprintf('Can\'t optimize image "%s": "%s"', $file->getPathname(), $e->getMessage()));
×
57
        }
58

59
        return $file->getContents();
1✔
60
    }
61

62
    /**
63
     * {@inheritdoc}
64
     */
65
    public function encode(string $content = null): ?string
66
    {
67
        return base64_encode((string) $content);
1✔
68
    }
69

70
    /**
71
     * {@inheritdoc}
72
     */
73
    public function decode(string $content = null): ?string
74
    {
75
        return base64_decode((string) $content);
1✔
76
    }
77
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc