Issues (4)

src/Infrastructure/AttachmentManager.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace ProjetNormandie\EmailBundle\Infrastructure;
4
5
use Swift_Attachment;
0 ignored issues
show
The type Swift_Attachment was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
/**
8
 * Utility class that manages the attachments defined from the Email entity to a Swift_Attachment.
9
 */
10
class AttachmentManager
11
{
12
    /**
13
     * Builds a Swift_Attachment object with management of filename.
14
     *
15
     * @param string $attachmentPath
16
     * @param string|int $name If integer, will be ignored.
17
     * @return Swift_Attachment
18
     */
19
    public static function buildSwift(string $attachmentPath, $name)
20
    {
21
        $file = Swift_Attachment::fromPath($attachmentPath);
22
        if (is_string($name)) {
23
            $file->setFilename($name);
24
        }
25
26
        return $file;
27
    }
28
}
29