Issues (42)

libraries/MessagePart.php (6 issues)

1
<?php
2
declare(strict_types=1);
3
4
defined('BASEPATH') OR exit('No direct script access allowed');
5
6
class MessagePart
7
{
8
  /**
9
   * [protected description]
10
   * @var [type]
0 ignored issues
show
Documentation Bug introduced by
The doc comment [type] at position 0 could not be parsed: Unknown type name '[' at position 0 in [type].
Loading history...
11
   */
12
  protected $part;
13
  /**
14
   * [__construct description]
15
   * @date  2019-11-23
16
   * @param [type]     $part [description]
0 ignored issues
show
Documentation Bug introduced by
The doc comment [type] at position 0 could not be parsed: Unknown type name '[' at position 0 in [type].
Loading history...
17
   */
18
  function __construct($part)
19
  {
20
    $this->part = $part;
21
  }
22
  /**
23
   * [__get description]
24
   * @date   2019-11-23
25
   * @param  string     $key [description]
26
   * @return [type]          [description]
0 ignored issues
show
Documentation Bug introduced by
The doc comment [type] at position 0 could not be parsed: Unknown type name '[' at position 0 in [type].
Loading history...
27
   */
28
  public function __get(string $key):string
29
  {
30
    return $this->part->{$key};
31
  }
32
  /**
33
   * [header description]
34
   * @date   2019-11-22
35
   * @param  string      $key [description]
36
   * @return string|null      [description]
37
   */
38
  public function header(string $key):?string
39
  {
40
    foreach ($this->part->headers as $header) {
41
      if ($header->name == $key) {
42
        return $header->value;
43
      }
44
    }
45
    return null;
46
  }
47
  /**
48
   * [getSize description]
49
   * @date   2019-11-23
50
   * @return int        [description]
51
   */
52
  public function getSize():int
53
  {
54
    return $this->part->body->size;
55
  }
56
  /**
57
   * [body description]
58
   * @date   2019-11-23
59
   * @param  integer    $partId [description]
60
   * @return [type]             [description]
0 ignored issues
show
Documentation Bug introduced by
The doc comment [type] at position 0 could not be parsed: Unknown type name '[' at position 0 in [type].
Loading history...
61
   */
62
  public function body(int $partId=0)
0 ignored issues
show
The parameter $partId is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

62
  public function body(/** @scrutinizer ignore-unused */ int $partId=0)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
63
  {
64
    return base64url_decode($this->part->body->data);
65
  }
66
}
67
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
68