DataListExtension   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 2
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A byURL() 0 4 1
1
<?php
2
3
namespace Ntb\RestAPI;
4
5
/**
6
 * Useful extensions for data lists.
7
 * @author Christian Blank <[email protected]>
8
 */
9
class DataListExtension extends \Extension {
10
11
    /**
12
     * Returns the first element in a data list, that has the given url segment.
13
     *
14
     * Works in the same way as DataList::byID.
15
     *
16
     * @param string $url the url segment
17
     * @return \DataObject the object, that has the given url segment
18
     */
19
    public function byURL($url) {
20
        $URL = \Convert::raw2sql($url);
21
        return $this->owner->filter('URLSegment', $URL)->first();
22
    }
23
}
24