Completed
Push — master ( cf0f44...2ab59a )
by Phecho
12:15 queued 07:33
created

ProjectHeaderHelper::getSearchQuery()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 28 and the first side effect is on line 19.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
/*
4
 * This file is part of Jitamin.
5
 *
6
 * Copyright (C) Jitamin Team
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Jitamin\Helper;
13
14
use Jitamin\Foundation\Base;
15
16
/**
17
 * Project Header Helper.
18
 */
19
class ProjectHeaderHelper extends Base
0 ignored issues
show
Bug introduced by
Possible parse error: class missing opening or closing brace
Loading history...
20
{
21
    /**
22
     * Get current query.
23
     *
24
     * @param array $project
25
     *
26
     * @return string
27
     */
28
    public function getSearchQuery(array $project)
29
    {
30
        $query = $this->request->getStringParam('q', $this->userSession->getFilters($project['id']));
31
        $this->userSession->setFilters($project['id'], $query);
32
33
        return urldecode($query);
34
    }
35
36
    /**
37
     * Render project header (views switcher and search box).
38
     *
39
<<<<<<< HEAD
40
     * @param array  $project
41
     * @param bool   $boardView
42
=======
43
     * @param array $project
44
     * @param bool  $boardView
45
>>>>>>> cf0f4459af2fc6f4fa0aac4c6c4655a0abc33333
46
     *
47
     * @return string
48
     */
49
    public function render(array $project, $boardView = false)
50
    {
51
<<<<<<< HEAD
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_SL
Loading history...
52
53
        return $this->template->render('project/_header/header', [
54
            'project'             => $project,
55
            'q'   => $this->getSearchQuery($project),
56
=======
57
        return $this->template->render('project/_header/header', [
58
            'project'             => $project,
59
            'q'                   => $this->getSearchQuery($project),
60
>>>>>>> cf0f4459af2fc6f4fa0aac4c6c4655a0abc33333
61
            'board_view'          => $boardView,
62
        ]);
63
    }
64
65
    /**
66
     * Get project description.
67
     *
68
     * @param array &$project
69
     *
70
     * @return string
71
     */
72
    public function getDescription(array &$project)
73
    {
74
        if ($project['owner_id'] > 0) {
75
            $description = t('Project owner: ').'**'.$this->helper->text->e($project['owner_name'] ?: $project['owner_username']).'**'.PHP_EOL.PHP_EOL;
76
77
            if (!empty($project['description'])) {
78
                $description .= '***'.PHP_EOL.PHP_EOL;
79
                $description .= $project['description'];
80
            }
81
        } else {
82
            $description = $project['description'];
83
        }
84
85
        return $description;
86
    }
87
}
88