Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
RevisionFormatterFactory
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
2
 create
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * Copyright (C) 2020 Kunal Mehta <legoktm@debian.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 */
20
21namespace Flow\Formatter;
22
23use Flow\Repository\UserNameBatch;
24use Flow\RevisionActionPermissions;
25use Flow\Templating;
26use Flow\UrlGenerator;
27
28/**
29 * The RevisionFormatter holds internal state like
30 * contentType of output and if it should include history
31 * properties.  To prevent different code using the formatter
32 * from causing problems we need to create a new RevisionFormatter
33 * every time it is requested.
34 */
35class RevisionFormatterFactory {
36
37    /** @var RevisionActionPermissions */
38    private $permissions;
39    /** @var Templating */
40    private $templating;
41    /** @var UrlGenerator */
42    private $urlGenerator;
43    /** @var UserNameBatch */
44    private $repositoryUsername;
45    /** @var int */
46    private $maxThreadingDepth;
47
48    public function __construct(
49        RevisionActionPermissions $permissions,
50        Templating $templating,
51        UrlGenerator $urlGenerator,
52        UserNameBatch $repositoryUsername,
53        $maxThreadingDepth
54    ) {
55        $this->permissions = $permissions;
56        $this->templating = $templating;
57        $this->urlGenerator = $urlGenerator;
58        $this->repositoryUsername = $repositoryUsername;
59        $this->maxThreadingDepth = $maxThreadingDepth;
60    }
61
62    public function create(): RevisionFormatter {
63        return new RevisionFormatter(
64            $this->permissions,
65            $this->templating,
66            $this->urlGenerator,
67            $this->repositoryUsername,
68            $this->maxThreadingDepth
69        );
70    }
71}