‪TYPO3CMS  ‪main
SummarizedReport.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
24 {
25  protected int ‪$count = 0;
29  protected array ‪$attributes = [];
30 
34  protected array ‪$mutationHashes = [];
35 
36  public function ‪withCount(int ‪$count): self
37  {
38  $target = clone $this;
39  $target->count = ‪$count;
40  return $target;
41  }
42 
43  public function ‪withAttribute(‪ReportAttribute $attribute): self
44  {
45  if (in_array($attribute, $this->attributes, true)) {
46  return $this;
47  }
48  $target = clone $this;
49  $target->attributes[] = $attribute;
50  return $target;
51  }
52 
53  public function ‪withMutationHashes(string ...‪$mutationHashes): self
54  {
55  if ($this->mutationHashes === ‪$mutationHashes) {
56  return $this;
57  }
58  $target = clone $this;
59  $target->mutationHashes = ‪$mutationHashes;
60  return $target;
61  }
62 
63  public function ‪jsonSerialize(): array
64  {
65  $data = parent::jsonSerialize();
66  $data['count'] = ‪$this->count;
67  $data['attributes'] = ‪$this->attributes;
68  $data['mutationHashes'] = ‪$this->mutationHashes;
69  return $data;
70  }
71 }
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Reporting\ReportAttribute
‪ReportAttribute
Definition: ReportAttribute.php:24
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Reporting\SummarizedReport\$count
‪int $count
Definition: SummarizedReport.php:25
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Reporting\SummarizedReport\withMutationHashes
‪withMutationHashes(string ... $mutationHashes)
Definition: SummarizedReport.php:53
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Reporting\SummarizedReport\jsonSerialize
‪jsonSerialize()
Definition: SummarizedReport.php:63
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Reporting
Definition: Report.php:18
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Reporting\SummarizedReport\$mutationHashes
‪array $mutationHashes
Definition: SummarizedReport.php:34
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Reporting\SummarizedReport\$attributes
‪array $attributes
Definition: SummarizedReport.php:29
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Reporting\Report
Definition: Report.php:27
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Reporting\SummarizedReport
Definition: SummarizedReport.php:24
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Reporting\SummarizedReport\withCount
‪withCount(int $count)
Definition: SummarizedReport.php:36
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\Reporting\SummarizedReport\withAttribute
‪withAttribute(ReportAttribute $attribute)
Definition: SummarizedReport.php:43