Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
CharsetAwareTrait
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 setContentType
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getCharSet
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setCharSet
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2declare(strict_types=1);
3/**
4 * Pop PHP Framework (https://www.popphp.org/)
5 *
6 * @link       https://github.com/popphp/popphp-framework
7 * @author     Nick Sagona, III <nick@popphp.org>
8 * @copyright  Copyright (c) 2009-2026 Nick Sagona, III
9 * @license    https://www.popphp.org/license     New BSD License
10 */
11
12namespace Pop\Mail\Message;
13
14/**
15 * Restores AbstractMessage's charset/content-type field concept on top of
16 * Pop\Mime\Part, which only models Content-Type as a header.
17 *
18 * @category   Pop
19 * @package    Pop\Mail
20 * @author     Nick Sagona, III <nick@popphp.org>
21 * @copyright  Copyright (c) 2009-2026 Nick Sagona, III
22 * @license    https://www.popphp.org/license     New BSD License
23 * @version    5.0.0
24 */
25trait CharsetAwareTrait
26{
27
28    /**
29     * Character set
30     * @var ?string
31     */
32    protected ?string $charSet = null;
33
34    /**
35     * Set Content-Type header
36     *
37     * @param  string $contentType
38     * @return static
39     */
40    public function setContentType(string $contentType): static
41    {
42        $this->addHeader('Content-Type', $contentType);
43        return $this;
44    }
45
46    /**
47     * Get character set
48     *
49     * @return ?string
50     */
51    public function getCharSet(): ?string
52    {
53        return $this->charSet;
54    }
55
56    /**
57     * Set character set
58     *
59     * @param  ?string $charSet
60     * @return static
61     */
62    public function setCharSet(?string $charSet = null): static
63    {
64        $this->charSet = $charSet;
65        return $this;
66    }
67
68}