[
  {
    "path": ".github/FUNDING.yml",
    "content": "github: eduardokum"
  },
  {
    "path": ".github/workflows/format_php.yml",
    "content": "name: Format (PHP)\n\non:\n  pull_request:\n    paths:\n      - \"**.php\"\n\njobs:\n  php-cs-fixer:\n    runs-on: ubuntu-latest\n    timeout-minutes: 5\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v4\n\n      - name: Setup PHP with php-cs-fixer\n        uses: shivammathur/setup-php@master\n        with:\n          php-version: '8.0'\n          tools: friendsofphp/php-cs-fixer:^2.19\n\n      - name: Run php-cs-fixer\n        run: php-cs-fixer fix\n\n      - uses: stefanzweifel/git-auto-commit-action@v4\n        with:\n          commit_message: Apply php-cs-fixer changes\n"
  },
  {
    "path": ".github/workflows/test.yml",
    "content": "name: Run unit tests\n\non:\n  - push\n  - pull_request\n\nenv:\n  COMPOSER_MEMORY_LIMIT: -1\n\njobs:\n  test:\n    runs-on: ${{ matrix.os }}\n\n    timeout-minutes: 10\n\n    strategy:\n      fail-fast: false\n      matrix:\n        php: [8.3, 8.2, 8.1, 8.0, 7.4, 7.3, 7.2]\n        laravel: ['6.*', '7.*', '8.*', '9.*', '10.*', '11.*', '12.*', '13.*']\n        os: [ubuntu-latest]\n        include:\n          - laravel: 12.*\n            testbench: 10.*\n          - laravel: 11.*\n            testbench: 9.*\n          - laravel: 10.*\n            testbench: 8.*\n          - laravel: 9.*\n            testbench: 7.*\n          - laravel: 8.*\n            testbench: 6.*\n          - laravel: 7.*\n            testbench: 5.*\n          - laravel: 6.*\n            testbench: 4.*\n          - laravel: 13.*\n            testbench: 11.*\n        exclude:\n          - laravel: 6.*\n            php: 8.1\n          - laravel: 6.*\n            php: 8.2\n          - laravel: 6.*\n            php: 8.3\n          - laravel: 7.*\n            php: 8.1\n          - laravel: 7.*\n            php: 8.2\n          - laravel: 7.*\n            php: 8.3\n          - laravel: 8.*\n            php: 7.2\n          - laravel: 8.*\n            php: 8.0\n          - laravel: 8.*\n            php: 8.1\n          - laravel: 8.*\n            php: 8.2\n          - laravel: 8.*\n            php: 8.3\n          - laravel: 9.*\n            php: 7.2\n          - laravel: 9.*\n            php: 7.3\n          - laravel: 9.*\n            php: 7.4\n          - laravel: 10.*\n            php: 7.2\n          - laravel: 10.*\n            php: 7.3\n          - laravel: 10.*\n            php: 7.4\n          - laravel: 10.*\n            php: 8.0\n          - laravel: 11.*\n            php: 7.2\n          - laravel: 11.*\n            php: 7.2\n          - laravel: 11.*\n            php: 7.3\n          - laravel: 11.*\n            php: 7.4\n          - laravel: 11.*\n            php: 8.0\n          - laravel: 11.*\n            php: 8.1\n          - laravel: 12.*\n            php: 7.2\n          - laravel: 12.*\n            php: 7.2\n          - laravel: 12.*\n            php: 7.3\n          - laravel: 12.*\n            php: 7.4\n          - laravel: 12.*\n            php: 8.0\n          - laravel: 12.*\n            php: 8.1\n          - laravel: 13.*\n            php: 8.2\n          - laravel: 13.*\n            php: 8.1\n          - laravel: 13.*\n            php: 8.0\n          - laravel: 13.*\n            php: 7.4\n          - laravel: 13.*\n            php: 7.3\n          - laravel: 13.*\n            php: 7.2\n\n    name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}\n\n    env:\n      extensions: exif, json, mbstring, dom\n\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v4\n\n      - name: Cache dependencies\n        uses: actions/cache@v4\n        with:\n          path: ~/.composer/cache/files\n          key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}\n\n      - name: Setup PHP extensions\n        id: cache-env\n        uses: shivammathur/cache-extensions@v1\n        with:\n          php-version: ${{ matrix.php }}\n          extensions: ${{ env.extensions }}\n          key: php-extensions-cache-v1\n\n      - name: Setup PHP ${{ matrix.php }}\n        uses: shivammathur/setup-php@v2\n        with:\n          php-version: ${{ matrix.php }}\n          extensions: ${{ env.extensions }}\n          coverage: none\n\n      - name: Install dependencies\n        run: composer require \"laravel/framework:${{ matrix.laravel }}\" \"orchestra/testbench:${{ matrix.testbench }}\" --no-interaction --no-update\n\n      - name: Update dependencies\n        run: composer update --prefer-dist --no-interaction\n\n      - name: Execute tests\n        run: vendor/bin/phpunit\n"
  },
  {
    "path": ".gitignore",
    "content": "/vendor\n/composer.lock\n.idea/\n.phpunit.result.cache"
  },
  {
    "path": ".php_cs.dist",
    "content": "<?php\n\n// copied from https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200\n\nuse PhpCsFixer\\Config;\nuse PhpCsFixer\\Finder;\n\n$rules = [\n    'array_syntax' => ['syntax' => 'short'],\n    'binary_operator_spaces' => [\n        'default' => 'single_space',\n        'operators' => ['=>' => null],\n    ],\n    'blank_line_after_namespace' => true,\n    'blank_line_after_opening_tag' => true,\n    'blank_line_before_statement' => [\n        'statements' => ['return'],\n    ],\n    'braces' => true,\n    'cast_spaces' => true,\n    'class_attributes_separation' => [\n        'elements' => ['method'],\n    ],\n    'class_definition' => true,\n    'concat_space' => [\n        'spacing' => 'none',\n    ],\n    'declare_equal_normalize' => true,\n    'elseif' => true,\n    'encoding' => true,\n    'full_opening_tag' => true,\n    'fully_qualified_strict_types' => true, // added by Shift\n    'function_declaration' => true,\n    'function_typehint_space' => true,\n    'heredoc_to_nowdoc' => true,\n    'include' => true,\n    'increment_style' => ['style' => 'post'],\n    'indentation_type' => true,\n    'linebreak_after_opening_tag' => true,\n    'line_ending' => true,\n    'lowercase_cast' => true,\n    'lowercase_constants' => true,\n    'lowercase_keywords' => true,\n    'lowercase_static_reference' => true, // added from Symfony\n    'magic_method_casing' => true, // added from Symfony\n    'magic_constant_casing' => true,\n    'method_argument_space' => true,\n    'native_function_casing' => true,\n    'no_alias_functions' => true,\n    'no_extra_blank_lines' => [\n        'tokens' => [\n            'extra',\n            'throw',\n            'use',\n            'use_trait',\n        ],\n    ],\n    'no_blank_lines_after_class_opening' => true,\n    'no_blank_lines_after_phpdoc' => true,\n    'no_closing_tag' => true,\n    'no_empty_phpdoc' => true,\n    'no_empty_statement' => true,\n    'no_leading_import_slash' => true,\n    'no_leading_namespace_whitespace' => true,\n    'no_mixed_echo_print' => [\n        'use' => 'echo',\n    ],\n    'no_multiline_whitespace_around_double_arrow' => true,\n    'multiline_whitespace_before_semicolons' => [\n        'strategy' => 'no_multi_line',\n    ],\n    'no_short_bool_cast' => true,\n    'no_singleline_whitespace_before_semicolons' => true,\n    'no_spaces_after_function_name' => true,\n    'no_spaces_around_offset' => true,\n    'no_spaces_inside_parenthesis' => true,\n    'no_trailing_comma_in_list_call' => true,\n    'no_trailing_comma_in_singleline_array' => true,\n    'no_trailing_whitespace' => true,\n    'no_trailing_whitespace_in_comment' => true,\n    'no_unneeded_control_parentheses' => true,\n    'no_unreachable_default_argument_value' => true,\n    'no_useless_return' => true,\n    'no_whitespace_before_comma_in_array' => true,\n    'no_whitespace_in_blank_line' => true,\n    'normalize_index_brace' => true,\n    'not_operator_with_successor_space' => true,\n    'object_operator_without_whitespace' => true,\n    'ordered_imports' => ['sortAlgorithm' => 'alpha'],\n    'phpdoc_indent' => true,\n    'phpdoc_inline_tag' => true,\n    'phpdoc_no_access' => true,\n    'phpdoc_no_package' => true,\n    'phpdoc_no_useless_inheritdoc' => true,\n    'phpdoc_scalar' => true,\n    'phpdoc_single_line_var_spacing' => true,\n    'phpdoc_summary' => true,\n    'phpdoc_to_comment' => true,\n    'phpdoc_trim' => true,\n    'phpdoc_types' => true,\n    'phpdoc_var_without_name' => true,\n    'psr4' => true,\n    'self_accessor' => true,\n    'short_scalar_cast' => true,\n    'simplified_null_return' => false, // disabled by Shift\n    'single_blank_line_at_eof' => true,\n    'single_blank_line_before_namespace' => true,\n    'single_class_element_per_statement' => true,\n    'single_import_per_statement' => true,\n    'single_line_after_imports' => true,\n    'single_line_comment_style' => [\n        'comment_types' => ['hash'],\n    ],\n    'single_quote' => true,\n    'space_after_semicolon' => true,\n    'standardize_not_equals' => true,\n    'switch_case_semicolon_to_colon' => true,\n    'switch_case_space' => true,\n    'ternary_operator_spaces' => true,\n    'trailing_comma_in_multiline_array' => true,\n    'trim_array_spaces' => true,\n    'unary_operator_spaces' => true,\n    'visibility_required' => [\n        'elements' => ['method', 'property'],\n    ],\n    'whitespace_after_comma_in_array' => true,\n];\n\n$finder = Finder::create()\n    ->in([\n        __DIR__.'/src',\n        __DIR__.'/config',\n        __DIR__.'/tests',\n    ])\n    ->name('*.php')\n    ->notName('*.blade.php')\n    ->ignoreDotFiles(true)\n    ->ignoreVCS(true);\n\nreturn Config::create()\n    ->setFinder($finder)\n    ->setRules($rules)\n    ->setRiskyAllowed(true)\n    // this is disabled, due to unexpected errors in some environments. Fell free to enable this to fits your needs.\n    ->setUsingCache(false);\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2017 Eduardo Gusmão\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "[![Packagist](https://img.shields.io/packagist/v/eduardokum/laravel-mail-auto-embed.svg?style=flat-square)](https://github.com/eduardokum/laravel-mail-auto-embed)\n[![Packagist](https://img.shields.io/packagist/dt/eduardokum/laravel-mail-auto-embed.svg?style=flat-square)](https://github.com/eduardokum/laravel-mail-auto-embed)\n[![Packagist](https://img.shields.io/packagist/l/eduardokum/laravel-mail-auto-embed.svg?style=flat-square)](https://github.com/eduardokum/laravel-mail-auto-embed)\n[![GitHub Actions](https://img.shields.io/endpoint.svg?style=flat-square&url=https%3A%2F%2Factions-badge.atrox.dev%2Feduardokum%2Flaravel-mail-auto-embed%2Fbadge)](https://actions-badge.atrox.dev/eduardokum/laravel-mail-auto-embed/goto)\n[![GitHub forks](https://img.shields.io/github/forks/eduardokum/laravel-mail-auto-embed.svg?color=lightgrey&style=flat-square)](https://github.com/eduardokum/laravel-mail-auto-embed)\n\n# Laravel Mail Auto Embed\n\nAutomatically parses your messages and embeds the images found into your mail,\nreplacing the original online-version of the image.\n\nShould work on Laravel 5.3+. Automatically tested for Laravel 5.4+ on PHP 7.0+.\n\n## Version Compatibility\n\n| Laravel | Package |\n|---------|---------|\n| \\< 8.x  | 1.x     |\n| \\> 9.x  | 2.x     |\n\n## Install\n\nYou can install the package via composer:\n```shell\ncomposer require eduardokum/laravel-mail-auto-embed\n```\n\nThis package uses Laravel 5.5 Package Auto-Discovery.\nFor previous versions of Laravel, you need to add the following Service\nProvider:\n\n```php\n$providers = [\n    ...\n    \\Eduardokum\\LaravelMailAutoEmbed\\ServiceProvider::class,\n    ...\n ];\n```\n\n\n## Usage\n\nIts use is very simple, you write your markdown normally:\n\n```markdown\n<!-- eg: resources/vendor/mail/markdown/order-shipped.blade.php -->\n@component('mail::message')\n# Order Shipped\n\nYour order has been shipped!\n\n@component('mail::button', ['url' => $url])\nView Order\n@endcomponent\n\nPurchased product:\n\n![product](https://domain.com/products/product-1.png)\n\nThanks,<br>\n{{ config('app.name') }}\n@endcomponent\n```\n\nWhen sending, it will replace the link that would normally be generated:\n> `<img src=\"https://domain.com/products/product-1.png\">`\n\nby an embedded inline attachment of the image:\n> `<img src=\"cid:3991f143cf1a86257f8671883736613c@Swift.generated\">`.\n\nIt works for raw html too:\n\n```html\n<!-- eg: resources/vendor/mail/html/header.blade.php -->\n<tr>\n    <td class=\"header\">\n        <a href=\"{{ $url }}\">\n            <img src=\"https://domain.com/logo.png\" class=\"img-header\">\n        </a>\n    </td>\n</tr>\n```\n\nIf you do not want to use automatic embedding for specific images (because they\nare hosted elsewhere, if you want to use some kind of image tracker, etc.),\nsimply add the attribute `data-skip-embed` in the image tag:\n\n```html\n<img src=\"https://domain.com/logo.png\" data-skip-embed class=\"img-header\">\n```\n### Local resources\n\nFor local resources that are not available publicly, use `file://` urls:\n\n```html\n<img src=\"file://{{ resource_path('assets/img/logo.png') }}\" alt=\"Logo\" border=\"0\"/>\n```\n\n## Configuration\n\nThe defaults are set in `config/mail-auto-embed.php`. You can copy this file to\nyour own config directory to modify the values using this command:\n\n```shell\nphp artisan vendor:publish --provider=\"Eduardokum\\LaravelMailAutoEmbed\\ServiceProvider\"\n```\n\n### Explicit embedding configuration\n\nBy default, images are embedded automatically, unless you add the\n`data-skip-embed` attribute.\n\nYou can also disable auto-embedding globally by setting the `MAIL_AUTO_EMBED`\nenvironment variable to `false`, or by modifying the `enabled` property in the\npublished config. You can then enable embedding for individual images with the\n`data-auto-embed` attribute.\n\n```env\n# .env\nMAIL_AUTO_EMBED=false\n```\n\n```php\nreturn [\n    /*\n    |--------------------------------------------------------------------------\n    | Mail auto embed\n    |--------------------------------------------------------------------------\n    |\n    | If true, images will be automatically embedded.\n    | If false, only images with the 'data-auto-embed' attribute will be embedded\n    |\n    */\n    'enabled' => false,\n\n    // …\n];\n```\n\n```html\n<p>\n    <!-- Won't be embedded -->\n    <img src=\"https://domain.com/logo.png\" class=\"img-header\">\n</p>\n<p>\n    <!-- Explicit embedding -->\n    <img src=\"https://domain.com/item.png\"  data-auto-embed>\n</p>\n```\n\n### Base64 embedding\n\nIf you prefer to use Base64 instead of inline attachments, you can do so by\nsetting the `MAIL_AUTO_EMBED_METHOD` environment variable or the `method`\nconfig property to `base64`.\n\n```php\nreturn [\n    // …\n\n    /*\n    |--------------------------------------------------------------------------\n    | Mail embed method\n    |--------------------------------------------------------------------------\n    |\n    | Supported: \"attachment\", \"base64\"\n    |\n    */\n    'method' => 'base64',\n];\n```\n\nNote that it will increase the e-mail size, and that it won't be decoded by\nsome e-mail clients such as Gmail.\n\n## Mixed embedding methods\n\nIf you want to use both inline attachment and Base64 depending on the image,\nyou can specify the embedding method as the `data-auto-embed` attribute value:\n\n```html\n<p>\n    <img src=\"https://domain.com/logo.png\" data-auto-embed=\"base64\">\n</p>\n<p>\n    <img src=\"https://domain.com/item.png\" data-auto-embed=\"attachment\">\n</p>\n```\n\n\n## Embedding entities\n\nYou might want to embed images that don't actually exist in your filesystem\n(stored in the database).\n\nIn that case, make the entities you want to embed implement the\n`EmbeddableEntity` interface:\n\n```php\nnamespace App\\Models;\n\nuse Eduardokum\\LaravelMailAutoEmbed\\Models\\EmbeddableEntity;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Picture extends Model implements EmbeddableEntity\n{\n    /**\n     * @param  mixed  $id\n     * @return Picture\n     */\n    public static function findEmbeddable($id)\n    {\n        return static::find($id);\n    }\n\n    /**\n     * @return mixed\n     */\n    public function getRawContent()\n    {\n        return $this->data;\n    }\n\n    /**\n     * @return string\n     */\n    public function getFileName()\n    {\n        return 'profile_'.$this->id.'.png';\n    }\n\n    /**\n     * @return string\n     */\n    public function getMimeType()\n    {\n        return 'image/png';\n    }\n}\n```\n\nThen, you can use the `embed:ClassName:id` syntax in your e-mail template:\n\n```html\n<p>\n    <img src=\"embed:App\\Models\\Picture:123\">\n</p>\n```\n\n## Contributing\nPlease feel free to submit pull requests if you can improve or add any\nfeatures.\n\nWe are currently using PSR-2. This is easy to implement and check with the PHP\nCoding Standards Fixer.\n\n<a target=\"_blank\" href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=QPDFT3UXS6PTL&lc=GB&item_name=laravel%2dmail%2dauto%2dembed&item_number=laravel%2dmail%2dauto%2dembed&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted\">\n        <img alt=\"Donate with Paypal\" src=\"https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif\"/></a>\n\n"
  },
  {
    "path": "composer.json",
    "content": "{\n    \"name\": \"eduardokum/laravel-mail-auto-embed\",\n    \"description\": \"Library for embed images in emails automatically\",\n    \"keywords\": [\n        \"eduardokum\",\n        \"laravel-mail-auto-embed\"\n    ],\n    \"homepage\": \"https://github.com/eduardokum/laravel-mail-auto-embed\",\n    \"license\": \"MIT\",\n    \"authors\": [\n        {\n            \"name\": \"Eduardo Gusmão\",\n            \"email\": \"eduguscontra3@hotmail.com\"\n        }\n    ],\n    \"require\": {\n        \"php\": \"^7.2|^8.0|^8.1|^8.2\",\n        \"ext-dom\": \"*\",\n        \"illuminate/contracts\": \"^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0\",\n        \"illuminate/support\": \"^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0\",\n        \"illuminate/mail\": \"^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0\",\n        \"masterminds/html5\": \"^2.7\",\n        \"ext-curl\": \"*\",\n        \"ext-fileinfo\": \"*\"\n    },\n    \"require-dev\": {\n        \"orchestra/testbench\": \"^4.0|^5.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0\",\n        \"phpunit/phpunit\": \"^8.5.30|^9.0|^10.0|^11.0|^12.5.12\",\n        \"squizlabs/php_codesniffer\": \"^3.5|^4.0\"\n    },\n    \"config\": {\n        \"sort-packages\": true\n    },\n    \"autoload\": {\n        \"psr-4\": {\n            \"Eduardokum\\\\LaravelMailAutoEmbed\\\\\": \"src\"\n        }\n    },\n    \"autoload-dev\": {\n        \"psr-4\": {\n            \"Eduardokum\\\\LaravelMailAutoEmbed\\\\Tests\\\\\": \"tests\"\n        }\n    },\n    \"extra\": {\n        \"laravel\": {\n            \"providers\": [\n                \"Eduardokum\\\\LaravelMailAutoEmbed\\\\ServiceProvider\"\n            ]\n        }\n    },\n    \"minimum-stability\": \"dev\",\n    \"prefer-stable\": true\n}\n"
  },
  {
    "path": "config/mail-auto-embed.php",
    "content": "<?php\n\nreturn [\n\n    /*\n    |--------------------------------------------------------------------------\n    | Mail auto embed\n    |--------------------------------------------------------------------------\n    |\n    | If true, images will be automatically embedded.\n    | If false, only images with the 'data-auto-embed' attribute will be embedded\n    |\n    */\n\n    'enabled' => env('MAIL_AUTO_EMBED', true),\n\n    /*\n    |--------------------------------------------------------------------------\n    | Mail embed method\n    |--------------------------------------------------------------------------\n    |\n    | Supported: \"attachment\", \"base64\"\n    |\n    */\n\n    'method' => env('MAIL_AUTO_EMBED_METHOD', 'attachment'),\n\n    'curl' => [\n        'connect_timeout' => 5, // Seconds\n        'timeout' => 10, // Seconds\n        'cache' => false,\n        'cache_ttl' => 3600,\n    ]\n];\n"
  },
  {
    "path": "phpunit.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phpunit xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         backupGlobals=\"false\"\n         bootstrap=\"vendor/autoload.php\"\n         colors=\"true\"\n         processIsolation=\"true\"\n         stopOnFailure=\"false\"\n         xsi:noNamespaceSchemaLocation=\"/phpunit.xsd\">\n    <testsuites>\n        <testsuite name=\"Application Test Suite\">\n            <directory suffix=\"Test.php\">./tests</directory>\n        </testsuite>\n    </testsuites>\n    <coverage>\n        <include>\n            <directory suffix=\".php\">./src</directory>\n        </include>\n    </coverage>\n</phpunit>\n"
  },
  {
    "path": "src/Contracts/Embedder/EntityEmbedder.php",
    "content": "<?php\n\nnamespace Eduardokum\\LaravelMailAutoEmbed\\Contracts\\Embedder;\n\nuse Eduardokum\\LaravelMailAutoEmbed\\Models\\EmbeddableEntity;\n\ninterface EntityEmbedder\n{\n    /**\n     * @param  EmbeddableEntity $entity\n     * @return string\n     */\n    public function fromEntity(EmbeddableEntity $entity);\n}\n"
  },
  {
    "path": "src/Contracts/Embedder/UrlEmbedder.php",
    "content": "<?php\n\nnamespace Eduardokum\\LaravelMailAutoEmbed\\Contracts\\Embedder;\n\ninterface UrlEmbedder\n{\n    /**\n     * @param  string  $url\n     * @return string\n     */\n    public function fromUrl($url);\n\n    /**\n     * @param  string  $path\n     * @return string\n     */\n    public function fromPath($path);\n\n/**\n     * @param string $base64\n     * @return string\n     */\n    public function fromBase64($base64);\n}\n"
  },
  {
    "path": "src/Contracts/Listeners/EmbedImages.php",
    "content": "<?php\r\n\r\nnamespace Eduardokum\\LaravelMailAutoEmbed\\Contracts\\Listeners;\r\n\r\ninterface EmbedImages\r\n{\r\n\r\n}"
  },
  {
    "path": "src/Embedder/AttachmentEmbedder.php",
    "content": "<?php\n\nnamespace Eduardokum\\LaravelMailAutoEmbed\\Embedder;\n\nuse Eduardokum\\LaravelMailAutoEmbed\\Models\\EmbeddableEntity;\nuse Exception;\nuse Illuminate\\Foundation\\Application;\nuse Illuminate\\Support\\Facades\\Cache;\nuse Illuminate\\Support\\Str;\nuse Swift_EmbeddedFile;\nuse Swift_Message;\nuse Symfony\\Component\\Mime\\Email;\n\nclass AttachmentEmbedder extends Embedder\n{\n    /**\n     * @var  Swift_Message\n     */\n    protected $swiftMessage;\n\n    /**\n     * @var  Email\n     */\n    protected $symfonyMessage;\n\n    /**\n     * @param Swift_Message $message\n     *\n     * @return AttachmentEmbedder\n     * @throws Exception\n     */\n    public function setSwiftMessage(Swift_Message $message)\n    {\n        if ($this->isLaravel9()) {\n            throw new Exception('Laravel 9 and greater must use symfony mailer');\n        }\n        $this->swiftMessage = $message;\n        return $this;\n    }\n\n    /**\n     * @param Email $message\n     *\n     * @return AttachmentEmbedder\n     * @throws Exception\n     */\n    public function setSymfonyMessage(Email $message)\n    {\n        if (!$this->isLaravel9()) {\n            throw new Exception('Laravel 8 and below must use swift mailer');\n        }\n        $this->symfonyMessage = $message;\n        return $this;\n    }\n\n    /**\n     * @param string $url\n     *\n     * @throws Exception\n     */\n    public function fromUrl($url)\n    {\n        $localFile = str_replace(url('/'), public_path(), $url);\n\n        if (file_exists($localFile)) {\n            return $this->fromPath($localFile);\n        }\n\n        if ($embeddedFromRemoteUrl = $this->fromRemoteUrl($url)) {\n            return $embeddedFromRemoteUrl;\n        }\n\n        return $url;\n    }\n\n    /**\n     * @param $path\n     *\n     * @return string\n     * @throws Exception\n     */\n    public function fromPath($path)\n    {\n        return $this->embed(file_get_contents($path), basename($path), mime_content_type($path));\n    }\n\n    /**\n     * @param string $base64\n     *\n     * @return string\n     * @throws Exception\n     */\n    public function fromBase64($base64)\n    {\n        $data = explode(',', $base64);\n        $type = explode(';', explode(':', $data[0])[1])[0];\n        $content = base64_decode($data[1]);\n        $name = Str::random();\n\n        return $this->embed($content, $name, $type);\n    }\n\n    /**\n     * @param EmbeddableEntity $entity\n     *\n     * @return string\n     * @throws Exception\n     */\n    public function fromEntity(EmbeddableEntity $entity)\n    {\n        return $this->embed($entity->getRawContent(), $entity->getFileName(), $entity->getMimeType());\n    }\n\n    /**\n     * @param string $url\n     *\n     * @throws Exception\n     */\n    public function fromRemoteUrl($url)\n    {\n        if (filter_var($url, FILTER_VALIDATE_URL)) {\n            $hashName = implode('_', [\n                'laravel-mail-auto-embed',\n                hash('sha256', $url)\n            ]);\n\n            if (config('mail-auto-embed.curl.cache', false) && $file = Cache::get($hashName)) {\n                return $this->embed($file['content'], $file['name'], $file['type']);\n            }\n\n            $ch = curl_init($url);\n            curl_setopt($ch, CURLOPT_HEADER, 0);\n            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\n            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);\n            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);\n            $raw = curl_exec($ch);\n            $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);\n            $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);\n            curl_close($ch);\n\n            if ($httpcode == 200) {\n                $pathInfo = pathinfo($url);\n\n                $queryStr = parse_url($url, PHP_URL_QUERY) ?: '';\n                parse_str($queryStr ?? '', $queryParams);\n                $basename = $queryParams['basename'] ?? $pathInfo['basename'];\n\n                if (config('mail-auto-embed.curl.cache', false)) {\n                    Cache::put($hashName, [\n                        'content' => $raw,\n                        'name' => $basename,\n                        'type' => $contentType\n                    ], config('mail-auto-embed.curl.cache_ttl', 3600));\n                }\n\n                return $this->embed($raw, $basename, $contentType);\n            }\n        }\n        return $url;\n    }\n\n    /**\n     * @param $body\n     * @param $name\n     * @param $type\n     *\n     * @return string\n     * @throws Exception\n     */\n    protected function embed($body, $name, $type)\n    {\n        if ($this->isLaravel9() && !empty($this->symfonyMessage)) {\n            if (gettype($name) !== 'string') {\n                $name = Str::random();\n            }\n            $this->symfonyMessage->embed($body, $name, $type);\n            return \"cid:$name\";\n        }\n\n        if (!$this->isLaravel9() && !empty($this->swiftMessage)) {\n            return $this->swiftMessage->embed(\n                new Swift_EmbeddedFile(\n                    $body,\n                    $name,\n                    $type\n                )\n            );\n        }\n\n        throw new Exception('No message defined');\n    }\n\n    /**\n     * @return bool\n     */\n    private function isLaravel9()\n    {\n        return version_compare(Application::VERSION, '9.0.0', '>=');\n    }\n}\n"
  },
  {
    "path": "src/Embedder/Base64Embedder.php",
    "content": "<?php\n\nnamespace Eduardokum\\LaravelMailAutoEmbed\\Embedder;\n\nuse Illuminate\\Support\\Arr;\nuse Eduardokum\\LaravelMailAutoEmbed\\Models\\EmbeddableEntity;\n\nclass Base64Embedder extends Embedder\n{\n    /**\n     * @var  array\n     */\n    private $config;\n\n    public function __construct($config)\n    {\n        $this->config = $config;\n    }\n\n    /**\n     * @param  string  $url\n     * @return string\n     */\n    public function fromUrl($url)\n    {\n        $localFile = str_replace(url('/'), public_path('/'), $url);\n        if (file_exists($localFile)) {\n            return $this->fromPath($localFile);\n        }\n\n        if ($embeddedFromRemoteUrl = $this->fromRemoteUrl($url)) {\n            return $embeddedFromRemoteUrl;\n        }\n\n        return $url;\n    }\n\n    /**\n     * @param $path\n     *\n     * @return string\n     */\n    public function fromPath($path)\n    {\n        if (file_exists($path)) {\n            return $this->base64String(mime_content_type($path), file_get_contents($path));\n        }\n\n        return $path;\n    }\n\n    /**\n     * @param  EmbeddableEntity  $entity\n     * @return string\n     */\n    public function fromEntity(EmbeddableEntity $entity)\n    {\n        return $this->base64String($entity->getMimeType(), $entity->getRawContent());\n    }\n\n    /**\n     * @param  string  $url\n     */\n    public function fromRemoteUrl($url)\n    {\n        if (filter_var($url, FILTER_VALIDATE_URL)) {\n            $ch = curl_init($url);\n            curl_setopt($ch, CURLOPT_HEADER, 0);\n            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, Arr::get($this->config, 'curl.connect_timeout', 5));\n            curl_setopt($ch, CURLOPT_TIMEOUT, Arr::get($this->config, 'curl.timeout', 10));\n            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\n            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);\n            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);\n            $raw = curl_exec($ch);\n            $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);\n            $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);\n            curl_close($ch);\n\n            if ($httpcode == 200) {\n                return $this->base64String($contentType, $raw);\n            }\n        }\n\n        return $url;\n    }\n\n    /**\n     * @param string $base64\n     * @return string\n     */\n    public function fromBase64($base64)\n    {\n        return $base64;\n    }\n\n    /**\n     * @param  string  $mimeType\n     * @param  mixed  $content\n     */\n    private function base64String($mimeType, $content)\n    {\n        return 'data:'.$mimeType.';base64,'.base64_encode($content);\n    }\n}\n"
  },
  {
    "path": "src/Embedder/Embedder.php",
    "content": "<?php\n\nnamespace Eduardokum\\LaravelMailAutoEmbed\\Embedder;\n\nuse Eduardokum\\LaravelMailAutoEmbed\\Contracts\\Embedder\\UrlEmbedder;\nuse Eduardokum\\LaravelMailAutoEmbed\\Contracts\\Embedder\\EntityEmbedder;\n\nabstract class Embedder implements UrlEmbedder, EntityEmbedder\n{\n}\n"
  },
  {
    "path": "src/Listeners/SwiftEmbedImages.php",
    "content": "<?php\n\nnamespace Eduardokum\\LaravelMailAutoEmbed\\Listeners;\n\nuse DOMDocument;\nuse DOMElement;\nuse Eduardokum\\LaravelMailAutoEmbed\\Embedder\\AttachmentEmbedder;\nuse Eduardokum\\LaravelMailAutoEmbed\\Embedder\\Base64Embedder;\nuse Eduardokum\\LaravelMailAutoEmbed\\Embedder\\Embedder;\nuse Eduardokum\\LaravelMailAutoEmbed\\Models\\EmbeddableEntity;\nuse Exception;\nuse Masterminds\\HTML5;\nuse ReflectionClass;\nuse Swift_Events_SendEvent;\nuse Swift_Events_SendListener;\nuse Swift_Message;\nuse Swift_Mime_SimpleMessage;\nuse Symfony\\Component\\Mime\\Email;\n\nclass SwiftEmbedImages implements Swift_Events_SendListener\n{\n    /**\n     * @var  array\n     */\n    private $config;\n\n    /**\n     * @var Email|Swift_Mime_SimpleMessage\n     */\n    private $message;\n\n    /**\n     * @param  array  $config\n     */\n    public function __construct($config)\n    {\n        $this->config = $config;\n    }\n\n    /**\n     * @param  Swift_Events_SendEvent  $evt\n     */\n    public function beforeSendPerformed(Swift_Events_SendEvent $evt)\n    {\n        $this->handle($evt->getMessage());\n    }\n\n    /**\n     * @param Swift_Mime_SimpleMessage $message\n     * @return void\n     */\n    public function handle(Swift_Mime_SimpleMessage $message)\n    {\n        $this->message = $message;\n        $this->attachImages();\n    }\n\n    /**\n     * @param  Swift_Events_SendEvent  $evt\n     * @return bool\n     */\n    public function sendPerformed(Swift_Events_SendEvent $evt)\n    {\n        return true;\n    }\n\n    /**\n     *\n     */\n    private function attachImages()\n    {\n        // Get body\n        $body = $this->message->getBody();\n\n        // Parse document\n        $parser = new HTML5();\n        $document = $parser->loadHTML($body);\n        if (! $document) {\n            // Cannot read\n            return;\n        }\n\n        // Invalid HTML (raw message)\n        if ($this->shouldSkipDocument($document)) {\n            return;\n        }\n\n        // Add images\n        $this->attachImagesToDom($document);\n\n        // Replace body\n        $this->message->setBody($parser->saveHTML($document));\n\n//        $html_body = $this->message->getBody();\n//\n        /*        $html_body = preg_replace_callback('/<img.*src=\"(.*?)\"\\s?(.*)?>/', [$this, 'replaceCallback'], $html_body);*/\n//\n//        $this->message->setBody($html_body);\n    }\n\n    /**\n     * @param  DOMDocument $document\n     * @return bool\n     */\n    private function shouldSkipDocument(DOMDocument $document)\n    {\n        if ($document->childNodes->count() != 1) {\n            return false;\n        }\n\n        if ($document->childNodes->item(0)->nodeType == XML_DOCUMENT_TYPE_NODE) {\n            return true;\n        }\n\n        return false;\n    }\n\n    /**\n     * @param DOMDocument $document\n     */\n    private function attachImagesToDom(DOMDocument &$document)\n    {\n        foreach ($document->getElementsByTagName('img') as $image) {\n            \\assert($image instanceof DOMElement);\n\n            // Skip if embed is not required\n            if ($this->needsEmbed($image)) {\n                // Get proper embedder\n                $embedder = $this->getEmbedder($image);\n\n                // Update src\n                $image->setAttribute('src', $this->embed(\n                    $embedder,\n                    $image->getAttribute('src')\n                ));\n            }\n\n            // Remove data properties\n            $image->removeAttribute('data-skip-embed');\n            $image->removeAttribute('data-auto-embed');\n        }\n    }\n\n    /**\n     * @param DOMElement $imageTag\n     * @return bool\n     */\n    private function needsEmbed(DOMElement $imageTag)\n    {\n        // Don't embed if 'data-skip-embed' is present\n        if ($imageTag->hasAttribute('data-skip-embed')) {\n            return false;\n        }\n\n        // Don't embed if auto-embed is disabled and 'data-auto-embed' is absent\n        if (! $this->config['enabled'] && ! $imageTag->hasAttribute('data-auto-embed')) {\n            return false;\n        }\n\n        return true;\n    }\n\n    /**\n     * @param DOMElement $imageTag\n     *\n     * @return Embedder\n     * @throws Exception\n     */\n    private function getEmbedder(DOMElement $imageTag)\n    {\n        $method = $imageTag->getAttribute('data-auto-embed');\n        if (empty($method)) {\n            $method = $this->config['method'];\n        }\n\n        switch ($method) {\n            case 'attachment':\n            default:\n                return (new AttachmentEmbedder())\n                    ->setSwiftMessage($this->message);\n            case 'base64':\n                return new Base64Embedder($this->config);\n        }\n    }\n\n    /**\n     * @param  Embedder  $embedder\n     * @param  string    $src\n     * @return string\n     */\n    private function embed(Embedder $embedder, $src)\n    {\n        // Entity embedding\n        if (strpos($src, 'embed:') === 0) {\n\n            $embedParams = explode(':', $src);\n            if (count($embedParams) < 3) {\n                return $src;\n            }\n\n            $className = urldecode($embedParams[1]);\n            $id = $embedParams[2];\n\n            if (!class_exists($className)) {\n                return $src;\n            }\n\n            $class = new ReflectionClass($className);\n            if (! $class->implementsInterface(EmbeddableEntity::class) ) {\n                return $src;\n            }\n\n            /** @var EmbeddableEntity $className */\n            if (! $instance = $className::findEmbeddable($id)) {\n                return $src;\n            }\n\n            return $embedder->fromEntity($instance);\n        }\n\n        // URL embedding\n        if (filter_var($src, FILTER_VALIDATE_URL) !== false) {\n            return $embedder->fromUrl($src);\n        }\n\n        $appPath = method_exists(app(), 'path') ? app_path($src) : null;\n        $publicPath = app()->bound('path.public') ? public_path($src) : null;\n        $storagePath = app()->bound('path.storage') ? storage_path($src) : null;\n        $storageAppPath = app()->bound('path.storage') ? storage_path(\"app/$src\") : null;\n        if (file_exists($src)) {\n            return $embedder->fromPath($src);\n        } elseif ($publicPath && file_exists($publicPath)) { // Try to guess where the file is at that priority level\n            return $embedder->fromPath($publicPath);\n        } elseif ($appPath && file_exists($appPath)) {\n            return $embedder->fromPath($appPath);\n        } elseif ($storagePath && file_exists($storagePath)) {\n            return $embedder->fromPath($storagePath);\n        } elseif ($storageAppPath && file_exists($storageAppPath)) {\n            return $embedder->fromPath($storageAppPath);\n        }\n\n        return $src;\n    }\n}"
  },
  {
    "path": "src/Listeners/SymfonyEmbedImages.php",
    "content": "<?php\n\nnamespace Eduardokum\\LaravelMailAutoEmbed\\Listeners;\n\nuse DOMDocument;\nuse DOMElement;\nuse Eduardokum\\LaravelMailAutoEmbed\\Embedder\\AttachmentEmbedder;\nuse Eduardokum\\LaravelMailAutoEmbed\\Embedder\\Base64Embedder;\nuse Eduardokum\\LaravelMailAutoEmbed\\Embedder\\Embedder;\nuse Eduardokum\\LaravelMailAutoEmbed\\Models\\EmbeddableEntity;\nuse Exception;\nuse Illuminate\\Mail\\Events\\MessageSending;\nuse Masterminds\\HTML5;\nuse ReflectionClass;\nuse Swift_Message;\nuse Symfony\\Component\\Mime\\Email;\n\nclass SymfonyEmbedImages\n{\n    /**\n     * @var  array\n     */\n    private $config;\n\n    /**\n     * @var  Email\n     */\n    private $message;\n\n    /**\n     * @param  array  $config\n     */\n    public function __construct($config)\n    {\n        $this->config = $config;\n    }\n\n    /**\n     * @param  MessageSending  $event\n     */\n    public function beforeSendPerformed(MessageSending $event)\n    {\n        $this->handle($event->message);\n    }\n\n    /**\n     * @param Email $message\n     * @return void\n     */\n    public function handle(Email $message)\n    {\n        $this->message = $message;\n        $this->attachImages();\n    }\n\n    /**\n     * Attaches images by parsing the HTML document.\n     */\n    private function attachImages()\n    {\n        // Get body\n        $body = $this->message->getHtmlBody();\n        if ($body === null) {\n            // Not an HTML message\n            return;\n        }\n\n        // Parse document\n        $parser = new HTML5();\n        $document = $parser->loadHTML($body);\n        if (! $document) {\n            // Cannot read\n            return;\n        }\n\n        // Add images\n        $this->attachImagesToDom($document);\n\n        // Replace body\n        $this->message->html($parser->saveHTML($document));\n    }\n\n    /**\n     * @param DOMDocument $document\n     *\n     * @return void\n     * @throws Exception\n     */\n    private function attachImagesToDom(DOMDocument &$document)\n    {\n        foreach ($document->getElementsByTagName('img') as $image) {\n            \\assert($image instanceof DOMElement);\n\n            // Skip if embed is not required\n            if ($this->needsEmbed($image)) {\n                // Get proper embedder\n                $embedder = $this->getEmbedder($image);\n                // Update src\n                $image->setAttribute('src', $this->embed(\n                    $embedder,\n                    $image->getAttribute('src')\n                ));\n            }\n\n            // Remove data properties\n            $image->removeAttribute('data-skip-embed');\n            $image->removeAttribute('data-auto-embed');\n        }\n    }\n\n    /**\n     * @param DOMElement $imageTag\n     *\n     * @return bool\n     */\n    private function needsEmbed(DOMElement $imageTag)\n    {\n        // Don't embed if 'data-skip-embed' is present\n        if ($imageTag->hasAttribute('data-skip-embed')) {\n            return false;\n        }\n\n        // Don't embed if auto-embed is disabled and 'data-auto-embed' is absent\n        if (! $this->config['enabled'] && ! $imageTag->hasAttribute('data-auto-embed')) {\n            return false;\n        }\n\n        return true;\n    }\n\n    /**\n     * @param DOMElement $imageTag\n     *\n     * @return Embedder\n     * @throws Exception\n     */\n    private function getEmbedder(DOMElement $imageTag)\n    {\n        $method = $imageTag->getAttribute('data-auto-embed');\n        if (empty($method)) {\n            $method = $this->config['method'];\n        }\n\n        switch ($method) {\n            case 'attachment':\n            default:\n                return (new AttachmentEmbedder())\n                    ->setSymfonyMessage($this->message);\n            case 'base64':\n                return new Base64Embedder($this->config);\n        }\n    }\n\n    /**\n     * @param  Embedder  $embedder\n     * @param  string    $src\n     * @return string\n     */\n    private function embed(Embedder $embedder, $src)\n    {\n        // Entity embedding\n        if (strpos($src, 'embed:') === 0) {\n            $embedParams = explode(':', $src);\n            if (count($embedParams) < 3) {\n                return $src;\n            }\n\n            $className = urldecode($embedParams[1]);\n            $id = $embedParams[2];\n\n            if (! class_exists($className)) {\n                return $src;\n            }\n\n            $class = new ReflectionClass($className);\n            if (! $class->implementsInterface(EmbeddableEntity::class)) {\n                return $src;\n            }\n\n            /** @var EmbeddableEntity $className */\n            if (! $instance = $className::findEmbeddable($id)) {\n                return $src;\n            }\n\n            return $embedder->fromEntity($instance);\n        }\n\n        // URL embedding\n        if (filter_var($src, FILTER_VALIDATE_URL) !== false) {\n            return $embedder->fromUrl($src);\n        }\n\n        // Base64 embedding\n        if (preg_match('/^data:image\\/[a-z]+;base64,/', $src)) {\n            return $embedder->fromBase64($src);\n        }\n\n        $appPath = method_exists(app(), 'path') ? app_path($src) : null;\n        $publicPath = app()->bound('path.public') ? public_path($src) : null;\n        $storagePath = app()->bound('path.storage') ? storage_path($src) : null;\n        $storageAppPath = app()->bound('path.storage') ? storage_path(\"app/$src\") : null;\n        if (file_exists($src)) {\n            return $embedder->fromPath($src);\n        } elseif ($publicPath && file_exists($publicPath)) { // Try to guess where the file is at that priority level\n            return $embedder->fromPath($publicPath);\n        } elseif ($appPath && file_exists($appPath)) {\n            return $embedder->fromPath($appPath);\n        } elseif ($storagePath && file_exists($storagePath)) {\n            return $embedder->fromPath($storagePath);\n        } elseif ($storageAppPath && file_exists($storageAppPath)) {\n            return $embedder->fromPath($storageAppPath);\n        }\n\n        return $src;\n    }\n}\n\n"
  },
  {
    "path": "src/Models/EmbeddableEntity.php",
    "content": "<?php\n\nnamespace Eduardokum\\LaravelMailAutoEmbed\\Models;\n\ninterface EmbeddableEntity\n{\n    /**\n     * @param  mixed  $id\n     * @return EmbeddableEntity|null\n     */\n    public static function findEmbeddable($id);\n\n    /**\n     * @return mixed\n     */\n    public function getRawContent();\n\n    /**\n     * @return string\n     */\n    public function getFileName();\n\n    /**\n     * @return string\n     */\n    public function getMimeType();\n}\n"
  },
  {
    "path": "src/ServiceProvider.php",
    "content": "<?php\n\nnamespace Eduardokum\\LaravelMailAutoEmbed;\n\nuse Eduardokum\\LaravelMailAutoEmbed\\Contracts\\Listeners\\EmbedImages;\nuse Eduardokum\\LaravelMailAutoEmbed\\Listeners\\SwiftEmbedImages;\nuse Eduardokum\\LaravelMailAutoEmbed\\Listeners\\SymfonyEmbedImages;\nuse Illuminate\\Foundation\\Application;\nuse Illuminate\\Mail\\Events\\MessageSending;\nuse Illuminate\\Support\\Arr;\nuse Illuminate\\Support\\Facades\\Event;\nuse Illuminate\\Support\\Facades\\Mail;\nuse Illuminate\\Support\\ServiceProvider as BaseServiceProvider;\nuse Throwable;\n\nclass ServiceProvider extends BaseServiceProvider\n{\n    /**\n     * Bootstrap the application services.\n     *\n     * @return void\n     */\n    public function boot()\n    {\n        $this->publishes([$this->getConfigPath() => config_path('mail-auto-embed.php')], 'config');\n\n        $this->app->singleton(EmbedImages::class, function($app) {\n            if (version_compare(Application::VERSION, '9.0.0', '>=')) {\n                return new SymfonyEmbedImages($app['config']->get('mail-auto-embed'));\n            }\n            return new SwiftEmbedImages($app['config']->get('mail-auto-embed'));\n        });\n\n        if (version_compare(Application::VERSION, '9.0.0', '>=')) {\n            Event::listen(function (MessageSending $event) {\n                $this->app->make(EmbedImages::class)->beforeSendPerformed($event);\n            });\n        } else {\n            foreach (Arr::get($this->app['config'], 'mail.mailers', []) as $driver => $mailer) {\n                try {\n                    // If transport not exists this will throw an exception\n                    Mail::driver($driver)->getSwiftMailer()->registerPlugin($this->app->make(EmbedImages::class));\n                } catch (Throwable $e) {}\n            }\n        }\n    }\n\n    /**\n     * Register the application services.\n     *\n     * @return void\n     */\n    public function register()\n    {\n        $this->mergeConfigFrom($this->getConfigPath(), 'mail-auto-embed');\n    }\n\n    /**\n     * @return string\n     */\n    protected function getConfigPath()\n    {\n        return __DIR__.'/../config/mail-auto-embed.php';\n    }\n}\n"
  },
  {
    "path": "tests/Embedder/AttachmentEmbedderTest.php",
    "content": "<?php\n\nnamespace Eduardokum\\LaravelMailAutoEmbed\\Tests\\Embedder;\n\nuse Eduardokum\\LaravelMailAutoEmbed\\Embedder\\AttachmentEmbedder;\nuse Eduardokum\\LaravelMailAutoEmbed\\Tests\\fixtures\\PictureEntity;\nuse Eduardokum\\LaravelMailAutoEmbed\\Tests\\TestCase;\nuse Swift_EmbeddedFile;\nuse Swift_Message;\n\nclass AttachmentEmbedderTest extends TestCase\n{\n    public function testOkAttachment(){\n        $this->assertTrue(true);\n    }\n//    /** @var Swift_Message */\n//    private $message;\n//\n//    /** @var AttachmentEmbedder */\n//    private $embedder;\n//\n//    /**\n//     * @before\n//     * @return void\n//     */\n//    protected function setUpEmbedder()\n//    {\n//        $this->message = new Swift_Message();\n//        $this->embedder = new AttachmentEmbedder($this->message);\n//    }\n//\n//    /**\n//     * @return int\n//     */\n//    private function getEmbeddedFilesCount()\n//    {\n//        return collect($this->message->getChildren())\n//            ->filter(\n//                function ($item) {\n//                    return $item instanceof Swift_EmbeddedFile;\n//                }\n//            )\n//            ->count();\n//    }\n//\n//    /**\n//     * @test\n//     */\n//    public function testLocalConversion()\n//    {\n//        $result = $this->embedder->fromUrl('http://localhost/test.png');\n//\n//        $this->assertStringStartsWith('cid:', $result);\n//\n//        $this->assertEquals(1, $this->getEmbeddedFilesCount());\n//    }\n//\n//    /**\n//     * @test\n//     */\n//    public function testEntityConversion()\n//    {\n//        $picture = new PictureEntity();\n//\n//        $result = $this->embedder->fromEntity($picture);\n//\n//        $this->assertStringStartsWith('cid:', $result);\n//\n//        $this->assertEquals(1, $this->getEmbeddedFilesCount());\n//    }\n//\n//    /**\n//     * @test\n//     */\n//    public function testRemoteUrl()\n//    {\n//        $result = $this->embedder->fromRemoteUrl('https://via.placeholder.com/1');\n//\n//        $this->assertStringStartsWith('cid:', $result);\n//\n//        $this->assertEquals(1, $this->getEmbeddedFilesCount());\n//    }\n}\n"
  },
  {
    "path": "tests/Embedder/Base64EmbedderTest.php",
    "content": "<?php\n\nnamespace Eduardokum\\LaravelMailAutoEmbed\\Tests\\Embedder;\n\nuse Eduardokum\\LaravelMailAutoEmbed\\Embedder\\Base64Embedder;\nuse Eduardokum\\LaravelMailAutoEmbed\\Tests\\fixtures\\PictureEntity;\nuse Eduardokum\\LaravelMailAutoEmbed\\Tests\\TestCase;\n\nclass Base64EmbedderTest extends TestCase\n{\n    public function testOkBase64(){\n        $this->assertTrue(true);\n    }\n//    /**\n//     * @before\n//     * @return void\n//     */\n//    protected function setUpEmbedder(): void\n//    {\n//        $this->embedder = new Base64Embedder();\n//    }\n//\n//    /**\n//     * @test\n//     */\n//    public function testLocalConversion()\n//    {\n//        $embedder = new Base64Embedder();\n//\n//        $result = $embedder->fromUrl('http://localhost/test.png');\n//\n//        $this->assertStringStartsWith('data:image/png;base64,', $result);\n//    }\n//\n//    /**\n//     * @test\n//     */\n//    public function testEntityConversion()\n//    {\n//        $embedder = new Base64Embedder();\n//\n//        $picture = new PictureEntity();\n//\n//        $result = $embedder->fromEntity($picture);\n//\n//        $this->assertStringStartsWith('data:image/png;base64,', $result);\n//    }\n//\n//    /**\n//     * @test\n//     */\n//    public function testRemoteUrl()\n//    {\n//        $result = $this->embedder->fromRemoteUrl('https://via.placeholder.com/1.png');\n//\n//        $this->assertStringStartsWith('data:image/png;base64,', $result);\n//    }\n}\n"
  },
  {
    "path": "tests/FormatTest.php",
    "content": "<?php\n\nnamespace Eduardokum\\LaravelMailAutoEmbed\\Tests;\n\nuse Eduardokum\\LaravelMailAutoEmbed\\Tests\\Traits\\InteractsWithMessage;\n\n/**\n * Tests some scenarios, like HTML5 mails and mail with \"invalid\" HTML that mail clients\n * like.\n */\nclass FormatTest extends TestCase\n{\n    use InteractsWithMessage;\n\n    private const HANDLE_CONFIG = [\n        'enabled' => true,\n        'method' => 'attachment',\n    ];\n\n    /**\n     * @test\n     */\n    public function testValidHtml5Message()\n    {\n        $message = $this->handleBeforeSendPerformedEvent('formats/html5-valid.html', self::HANDLE_CONFIG);\n\n        $this->assertEmailImageTags([\n            'url' => 'cid:',\n            'entity' => 'cid:',\n        ], $message);\n    }\n\n    /**\n     * @test\n     */\n    public function testUserGeneratedHtml5Message()\n    {\n        $message = $this->handleBeforeSendPerformedEvent('formats/html5-user-generated.html', self::HANDLE_CONFIG);\n\n        $this->assertEmailImageTags([\n            'url' => 'cid:',\n            'entity' => 'cid:',\n        ], $message);\n    }\n}\n"
  },
  {
    "path": "tests/MailTest.php",
    "content": "<?php\n\nnamespace Eduardokum\\LaravelMailAutoEmbed\\Tests;\n\nuse Eduardokum\\LaravelMailAutoEmbed\\Listeners\\SwiftEmbedImages;\nuse Eduardokum\\LaravelMailAutoEmbed\\Tests\\Traits\\InteractsWithMessage;\n\nclass MailTest extends TestCase\n{\n    use InteractsWithMessage;\n\n    /**\n     * @test\n     */\n    public function testAutomaticAttachmentConversion()\n    {\n        $message = $this->handleBeforeSendPerformedEvent('embed-when-enabled.html', [\n            'enabled' => true,\n            'method' => 'attachment',\n        ]);\n\n        $this->assertEmailImageTags([\n            'url' => 'cid:',\n            'entity' => 'cid:',\n        ], $message);\n    }\n\n    /**\n     * @test\n     */\n    public function testSkippedConversions()\n    {\n        $message = $this->handleBeforeSendPerformedEvent('embed-can-skip.html', [\n            'enabled' => true,\n            'method' => 'attachment',\n        ]);\n\n        $this->assertEmailImageTags([\n            'embed' => 'cid:',\n            'skip' => 'http://localhost/test.png',\n        ], $message);\n    }\n\n    /**\n     * @test\n     */\n    public function testManualConversions()\n    {\n        $message = $this->handleBeforeSendPerformedEvent('manual-embed-when-disabled.html', [\n            'enabled' => false,\n            'method' => 'attachment',\n        ]);\n\n        $this->assertEmailImageTags([\n            'ignore' => 'http://localhost/test.png',\n            'embed' => 'cid:',\n        ], $message);\n    }\n\n    /**\n     * @test\n     */\n    public function testOverrideTypeBase64()\n    {\n        $message = $this->handleBeforeSendPerformedEvent('override-to-base64.html', [\n            'enabled' => true,\n            'method' => 'attachment',\n        ]);\n\n        $this->assertEmailImageTags([\n            'attachment' => 'cid:',\n            'base64' => 'data:image/png;base64,',\n        ], $message);\n    }\n\n    /**\n     * @test\n     */\n    public function testOverrideTypeAttachment()\n    {\n        $message = $this->handleBeforeSendPerformedEvent('override-to-attachment.html', [\n            'enabled' => true,\n            'method' => 'base64',\n        ]);\n\n        $this->assertEmailImageTags([\n            'attachment' => 'cid:',\n            'base64' => 'data:image/png;base64,',\n        ], $message);\n    }\n\n    /**\n     * @test\n     */\n    public function testGracefulFailureWithAttachments()\n    {\n        $message = $this->handleBeforeSendPerformedEvent('graceful-fails.html', [\n            'enabled' => true,\n            'method' => 'attachment',\n        ]);\n\n        $this->assertEmailImageTags([\n            'host' => 'http://example.com/test.png',\n            'image' => 'http://localhost/other.png',\n            'source' => 'whatever',\n            'syntax' => 'embed:whatever',\n            'class' => 'embed:WrongEntityClassName:1',\n            'implementation' => 'embed:Eduardokum\\\\LaravelMailAutoEmbed\\\\Tests\\\\fixtures\\\\WrongEntity:1',\n            'not found' => 'embed:Eduardokum\\\\LaravelMailAutoEmbed\\\\Tests\\\\fixtures\\\\PictureEntity:9',\n        ], $message);\n    }\n\n    /**\n     * @test\n     */\n    public function testGracefulFailureWithBase64()\n    {\n        $message = $this->handleBeforeSendPerformedEvent('graceful-fails.html', [\n            'enabled' => true,\n            'method' => 'base64',\n        ]);\n\n        $this->assertEmailImageTags([\n            'host' => 'http://example.com/test.png',\n            'image' => 'http://localhost/other.png',\n            'source' => 'whatever',\n            'syntax' => 'embed:whatever',\n            'class' => 'embed:WrongEntityClassName:1',\n            'implementation' => 'embed:Eduardokum\\\\LaravelMailAutoEmbed\\\\Tests\\\\fixtures\\\\WrongEntity:1',\n            'not found' => 'embed:Eduardokum\\\\LaravelMailAutoEmbed\\\\Tests\\\\fixtures\\\\PictureEntity:9',\n        ], $message);\n    }\n\n    /**\n     * @test\n     */\n    public function testDoesntHandleSendPerformedEvent()\n    {\n        if ($this->isLaravel9()) {\n            $this->assertTrue(true);\n        } else {\n            $message = $this->createMessage('<h1>Test</h1>');\n\n            $embedPlugin = new SwiftEmbedImages(['enabled' => true, 'method' => 'attachment']);\n\n            $this->assertTrue(\n                $embedPlugin->sendPerformed($this->createSwiftEvent($message))\n            );\n        }\n    }\n\n    /**\n     * @test\n     */\n    public function testDoesntTransformRawMessages()\n    {\n        $message = $this->handleBeforeSendPerformedEvent('raw-message.txt', [\n            'enabled' => true,\n            'method' => 'attachment',\n        ]);\n\n        $this->assertEquals(\n            $this->getLibraryFile('raw-message.txt'),\n            ($this->isLaravel9() ? $message->getTextBody() : $message->getBody())\n        );\n    }\n\n    /**\n     * @test\n     */\n    public function testDoesNotCreateHtmlBodyForSymfonyRawMessage()\n    {\n        if (! $this->isLaravel9()) {\n            $this->assertTrue(true);\n\n            return;\n        }\n\n        $message = $this->handleBeforeSendPerformedEvent(\n            'raw-message.txt',\n            ['enabled' => true, 'method' => 'attachment'],\n            true\n        );\n\n        $this->assertNull($message->getHtmlBody());\n    }\n}\n"
  },
  {
    "path": "tests/TestCase.php",
    "content": "<?php\n\nnamespace Eduardokum\\LaravelMailAutoEmbed\\Tests;\n\nuse Illuminate\\Foundation\\Application;\n\nclass TestCase extends \\Orchestra\\Testbench\\TestCase\n{\n    /**\n     * Define environment setup.\n     *\n     * @param  \\Illuminate\\Foundation\\Application  $app\n     * @return void\n     */\n    protected function getEnvironmentSetUp($app)\n    {\n        $path = __DIR__ . '/fixtures';\n\n        if(version_compare(Application::VERSION, '10', '<')){\n            $app['path.public'] = $path;\n        }else{\n            $app->usePublicPath($path);\n        }\n    }\n\n    /**\n     * @param  \\Illuminate\\Foundation\\Application  $app\n     * @return array\n     */\n    protected function getPackageProviders($app)\n    {\n        return [\\Eduardokum\\LaravelMailAutoEmbed\\ServiceProvider::class];\n    }\n\n    /**\n     * Returns a library file.\n     * @param string $name\n     * @return string\n     */\n    protected function getLibraryFile($name)\n    {\n        $path = __DIR__.'/lib/'.$name;\n        if (! \\file_exists($path) || ! \\is_file($path)) {\n            $this->fail(\"Cannot find {$name} in file library\");\n        }\n\n        return \\file_get_contents($path);\n    }\n}\n"
  },
  {
    "path": "tests/Traits/InteractsWithMessage.php",
    "content": "<?php\n\nnamespace Eduardokum\\LaravelMailAutoEmbed\\Tests\\Traits;\n\nuse Eduardokum\\LaravelMailAutoEmbed\\Listeners\\SwiftEmbedImages;\nuse Eduardokum\\LaravelMailAutoEmbed\\Listeners\\SymfonyEmbedImages;\nuse Illuminate\\Mail\\Events\\MessageSending;\nuse Swift_Message;\nuse Symfony\\Component\\Mime\\Email;\n\n/**\n * Shared code for creating messages and events.\n */\ntrait InteractsWithMessage\n{\n    /**\n     * @return bool\n     */\n    private function isLaravel9()\n    {\n        return version_compare($this->createApplication()->version(), '9.0.0', '>=');\n    }\n\n    /**\n     * @param  string  $htmlMessage\n     * @param  bool    $isRawMessage\n     *\n     * @return Email|Swift_Message\n     */\n    protected function createMessage($htmlMessage, $isRawMessage = false)\n    {\n        if ($this->isLaravel9()) {\n            return (new Email())->to('test@test.com')->from('sender@test.com')->subject('test')\n                ->text($htmlMessage)\n                ->html($isRawMessage ? null : $htmlMessage);\n        } else {\n            return new Swift_Message('test', $htmlMessage, $isRawMessage ? 'text/plain' : null);\n        }\n    }\n\n    /**\n     * @param  Swift_Message  $message\n     * @return \\Swift_Events_SendEvent\n     */\n    protected function createSwiftEvent(Swift_Message $message)\n    {\n        $dispatcher = new \\Swift_Events_SimpleEventDispatcher();\n        $transport = new \\Swift_Transport_NullTransport($dispatcher);\n        $event = new \\Swift_Events_SendEvent($transport, $message);\n\n        return $event;\n    }\n\n    /**\n     * @param  string  $libraryFile\n     * @param  array   $options\n     * @param  bool    $isRawMessage\n     * @return Swift_Message|Email\n     */\n    protected function handleBeforeSendPerformedEvent($libraryFile, $options, $isRawMessage = false)\n    {\n        $htmlMessage = $this->getLibraryFile($libraryFile);\n        $message = $this->createMessage($htmlMessage, $isRawMessage);\n\n        if ($this->isLaravel9()) {\n            $event = new MessageSending($message);\n            (new SymfonyEmbedImages($options))\n                ->beforeSendPerformed($event);\n            $event->message->getBody();\n            return $event->message;\n        }\n\n        $embedPlugin = new SwiftEmbedImages($options);\n        $embedPlugin->beforeSendPerformed($this->createSwiftEvent($message));\n\n        return $message;\n    }\n\n    /**\n     * Check the body for image tags with the given keys as comment preceding them.\n     * @param array $expectations\n     * @param string $body\n     * @return void\n     */\n    protected function assertEmailImageTags($expectations, $body)\n    {\n        foreach ($expectations as $comment => $src) {\n            // Fix for PHPUnit <8.0\n            // phpcs:ignore Generic.Files.LineLength.TooLong\n            $method = \\method_exists($this, 'assertStringContainsString') ? 'assertStringContainsString' : 'assertContains';\n\n            // Check if the string is contained within the string\n            $this->$method(\n                sprintf('<!-- %s --><img src=\"%s', $comment, $src),\n                $this->isLaravel9() ? $body->getHtmlBody() : $body->getBody()\n            );\n        }\n    }\n}\n"
  },
  {
    "path": "tests/fixtures/PictureEntity.php",
    "content": "<?php\n\nnamespace Eduardokum\\LaravelMailAutoEmbed\\Tests\\fixtures;\n\nuse Eduardokum\\LaravelMailAutoEmbed\\Models\\EmbeddableEntity;\n\nclass PictureEntity implements EmbeddableEntity\n{\n    /**\n     * @param  mixed  $id\n     * @return EmbeddableEntity|null\n     */\n    public static function findEmbeddable($id)\n    {\n        if ($id == '1') {\n            return new static();\n        }\n\n        return null;\n    }\n\n    /**\n     * @return mixed\n     */\n    public function getRawContent()\n    {\n        return file_get_contents(public_path('test.png'));\n    }\n\n    /**\n     * @return string\n     */\n    public function getFileName()\n    {\n        return 'test.png';\n    }\n\n    /**\n     * @return string\n     */\n    public function getMimeType()\n    {\n        return 'image/png';\n    }\n}\n"
  },
  {
    "path": "tests/fixtures/WrongEntity.php",
    "content": "<?php\n\nnamespace Eduardokum\\LaravelMailAutoEmbed\\Tests\\fixtures;\n\nclass WrongEntity\n{\n}\n"
  },
  {
    "path": "tests/lib/embed-can-skip.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"utf-8\">\n</head>\n<body>\n    <!-- embed --><img src=\"http://localhost/test.png\" />\n    <!-- skip --><img src=\"http://localhost/test.png\" data-skip-embed />\n</body>\n</html>\n"
  },
  {
    "path": "tests/lib/embed-when-enabled.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"utf-8\">\n</head>\n<body>\n    <!-- url --><img src=\"http://localhost/test.png\" />\n    <!-- entity --><img src=\"embed:Eduardokum\\LaravelMailAutoEmbed\\Tests\\fixtures\\PictureEntity:1\" />\n</body>\n</html>\n"
  },
  {
    "path": "tests/lib/formats/html5-custom-embeds.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n    <meta charset=\"utf-8\">\n</head>\n\n<body>\n    <main>\n        <article>\n            <p>\n                Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla, dolorum assumenda aliquam blanditiis,\n                necessitatibus mollitia delectus sapiente amet earum minima qui non deserunt quidem, doloremque\n                architecto voluptatem eveniet illo aperiam.\n            </p>\n\n            <p>\n                <figure>\n                    <!-- default --><img src=\"http://localhost/test.png\" />\n                    <caption>Lorem ipsum</caption>\n                </figure>\n            </p>\n        </article>\n\n        <aside>\n            <header>\n                <h1>Lorem Ipsum</h1>\n            </header>\n\n            <p>\n                Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore cum, blanditiis a minima aspernatur\n                corporis pariatur, perferendis explicabo consectetur tenetur iste, fuga possimus corrupti dolorem\n                laudantium sapiente sunt error autem.\n            </p>\n\n            <figure>\n                <!-- custom embedder --><img data-auto-embed=\"custom\" src=\"http://localhost/test.png\" />\n                <caption>Lorem Ipsum</caption>\n            </figure>\n        </aside>\n\n\n        <aside>\n            <header>\n                <h1>Lorem Ipsum Two</h1>\n            </header>\n\n            <p>\n                Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore cum, blanditiis a minima aspernatur\n                corporis pariatur, perferendis explicabo consectetur tenetur iste, fuga possimus corrupti dolorem\n                laudantium sapiente sunt error autem.\n            </p>\n\n            <figure>\n                <!-- invalid embedder --><img data-auto-embed=\"unknown\" src=\"http://localhost/test.png\" />\n                <caption>Lorem Ipsum</caption>\n            </figure>\n        </aside>\n    </main>\n</body>\n\n</html>\n"
  },
  {
    "path": "tests/lib/formats/html5-user-generated.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n    <meta charset=\"utf-8\">\n</head>\n\n<body>\n    <main>\n        <article>\n            <h1>Lorem Ipsum</h1>\n\n            <p>\n                Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla, dolorum assumenda aliquam blanditiis,\n                necessitatibus mollitia delectus sapiente amet earum minima qui non deserunt quidem, doloremque\n                architecto voluptatem eveniet illo aperiam.\n            </p>\n\n            <p>\n                <!-- Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/colgroup -->\n                <table>\n                    <caption>Superheros and sidekicks</caption>\n                    <colgroup>\n                        <col>\n                        <col span=\"2\" class=\"batman\">\n                        <col span=\"2\" class=\"flash\">\n                    </colgroup>\n                    <tr>\n                        <td> </td>\n                        <th scope=\"col\">Batman</th>\n                        <th scope=\"col\">Robin</th>\n                        <th scope=\"col\">The Flash</th>\n                        <th scope=\"col\">Kid Flash</th>\n                    </tr>\n                    <tr>\n                        <th scope=\"row\">Skill</th>\n                        <td>Smarts</td>\n                        <td>Dex, acrobat</td>\n                        <td>Super speed</td>\n                        <td>Super speed</td>\n                    </tr>\n                </table>\n            </p>\n\n            <p>\n                <figure>\n                    <!-- url --><img src=\"http://localhost/test.png\" />\n                    <caption>Lorem ipsum</caption>\n                </figure>\n            </p>\n        </article>\n\n        <aside>\n            <header>\n                <h1>Lorem Ipsum</h1>\n            </header>\n\n            <p>\n                Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore cum, blanditiis a minima aspernatur\n                corporis pariatur, perferendis explicabo consectetur tenetur iste, fuga possimus corrupti dolorem\n                laudantium sapiente sunt error autem.\n            </p>\n\n            <figure>\n                <!-- entity --><img src=\"embed:Eduardokum\\LaravelMailAutoEmbed\\Tests\\fixtures\\PictureEntity:1\" />\n                <caption>Lorem Ipsum</caption>\n            </figure>\n        </aside>\n    </main>\n</body>\n\n</html>\n"
  },
  {
    "path": "tests/lib/formats/html5-valid.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n    <meta charset=\"utf-8\">\n</head>\n\n<body>\n    <main>\n        <article>\n            <h1>Lorem Ipsum</h1>\n\n            <p>\n                Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla, dolorum assumenda aliquam blanditiis,\n                necessitatibus mollitia delectus sapiente amet earum minima qui non deserunt quidem, doloremque\n                architecto voluptatem eveniet illo aperiam.\n            </p>\n\n\n            <figure>\n                <!-- url --><img src=\"http://localhost/test.png\" />\n                <caption>Lorem ipsum</caption>\n            </figure>\n        </article>\n\n        <aside>\n            <header>\n                <h1>Lorem Ipsum</h1>\n            </header>\n\n            <p>\n                Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore cum, blanditiis a minima aspernatur\n                corporis pariatur, perferendis explicabo consectetur tenetur iste, fuga possimus corrupti dolorem\n                laudantium sapiente sunt error autem.\n            </p>\n\n            <figure>\n                <!-- entity --><img src=\"embed:Eduardokum\\LaravelMailAutoEmbed\\Tests\\fixtures\\PictureEntity:1\" />\n                <caption>Lorem Ipsum</caption>\n            </figure>\n        </aside>\n    </main>\n</body>\n\n</html>\n"
  },
  {
    "path": "tests/lib/graceful-fails.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"utf-8\">\n</head>\n<body>\n    <!-- host --><img src=\"http://example.com/test.png\" />\n    <!-- image --><img src=\"http://localhost/other.png\" />\n    <!-- source --><img src=\"whatever\" />\n    <!-- syntax --><img src=\"embed:whatever\" />\n    <!-- class --><img src=\"embed:WrongEntityClassName:1\" />\n    <!-- implementation --><img src=\"embed:Eduardokum\\LaravelMailAutoEmbed\\Tests\\fixtures\\WrongEntity:1\" />\n    <!-- not found --><img src=\"embed:Eduardokum\\LaravelMailAutoEmbed\\Tests\\fixtures\\PictureEntity:9\" />\n</body>\n</html>\n"
  },
  {
    "path": "tests/lib/manual-embed-when-disabled.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"utf-8\">\n</head>\n<body>\n    <!-- ignore --><img src=\"http://localhost/test.png\" />\n    <!-- embed --><img src=\"http://localhost/test.png\" data-auto-embed />\n</body>\n</html>\n"
  },
  {
    "path": "tests/lib/override-to-attachment.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"utf-8\">\n</head>\n<body>\n    <!-- attachment --><img src=\"http://localhost/test.png\" data-auto-embed=\"attachment\" />\n    <!-- base64 --><img src=\"http://localhost/test.png\" />\n</body>\n</html>\n"
  },
  {
    "path": "tests/lib/override-to-base64.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"utf-8\">\n</head>\n<body>\n    <!-- attachment --><img src=\"http://localhost/test.png\" />\n    <!-- base64 --><img src=\"http://localhost/test.png\" data-auto-embed=\"base64\" />\n</body>\n</html>\n"
  },
  {
    "path": "tests/lib/raw-message.txt",
    "content": "The is a raw message that should be skipped.\nIt doesn't contain any images.\n"
  }
]