DocumentHelper   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 22
wmc 5
lcom 0
cbo 2
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getDebugTitle() 0 12 5
1
<?php
2
3
/*
4
 * This file is part of Sulu.
5
 *
6
 * (c) MASSIVE ART WebServices GmbH
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Sulu\Component\DocumentManager;
13
14
use Sulu\Component\DocumentManager\Behavior\Mapping\PathBehavior;
15
use Sulu\Component\DocumentManager\Behavior\Mapping\TitleBehavior;
16
17
class DocumentHelper
18
{
19
    /**
20
     * Return a debug title for the document for use in exception messages.
21
     *
22
     * @param $document
23
     *
24
     * @return string
25
     */
26
    public static function getDebugTitle($document)
27
    {
28
        $title = spl_object_hash($document);
29
30
        if ($document instanceof PathBehavior && $document->getPath()) {
31
            $title .= ' (' . $document->getPath() . ')';
32
        } elseif ($document instanceof TitleBehavior && $document->getTitle()) {
33
            $title .= ' (' . $document->getTitle() . ')';
34
        }
35
36
        return $title;
37
    }
38
}
39