Completed
Push — master ( 1741bf...ba793d )
by
unknown
02:02
created

src/cli/cms/data/fileAttr.js   A

Size

Lines of Code 45

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
nc 1
dl 0
loc 45
rs 10
noi 4

1 Function

Rating   Name   Duplication   Size   Complexity  
A fileAttr.js ➔ ??? 0 4 1
1
import attr from "./attr";
2
3
/**
4
 * Class FileAttr
5
 * Manage string with attributes encoded inside
6
 */
7
export default class FileAttr {
8
9
  /**
10
   * Add attributes or modify them if they already exists
11
   * @param {String} str the string to modify
12
   * @param {Object} options object with attributes to add
13
   * @return {String} the string with the new attributes
14
   */
15
  static add(str, options) {
16
    var att = new attr(str)
0 ignored issues
show
Coding Style Best Practice introduced by
By convention, constructors like attr should be capitalized.
Loading history...
17
    return att.insert(options)
18
  }
19
20
  /**
21
   * Remove attributes from string
22
   * @param {String} str the string to modify
23
   * @return {String} the string modified
24
   */
25
  static delete(str) {
26
    return new attr(str).remove()
0 ignored issues
show
Coding Style Best Practice introduced by
By convention, constructors like attr should be capitalized.
Loading history...
27
  }
28
29
  /**
30
   * @param  {String} str the string to get attributes from
31
   * @return {object|String} object (all the attributes) if the key is null, if not the value of the atrtibuts
32
   */
33
  static get(str) {
34
    return new attr(str).val
0 ignored issues
show
Coding Style Best Practice introduced by
By convention, constructors like attr should be capitalized.
Loading history...
35
  }
36
37
  /**
38
   * @param  {String} str the string to test attributes from
39
   * @return {boolean} true if string has attr
40
   */
41
  static test(str) {
42
    var att = new attr(str).val
0 ignored issues
show
Coding Style Best Practice introduced by
By convention, constructors like attr should be capitalized.
Loading history...
43
    return (typeof att.s !== 'undefined' && att.s !== null)
44
  }
45
}
46
47