DocumentHelper::getDebugTitle()   B
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 12
rs 8.8571
cc 5
eloc 7
nc 3
nop 1
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