1+ # frozen_string_literal: true
2+
13module PhcStringFormat
24 #
35 # Parser for parsing PHC-string-format.
@@ -8,8 +10,8 @@ class PhcString
810 def self . parse ( string )
911 string ||= ''
1012 PhcString . new ( *split ( string ) )
11- rescue StandardError => exception
12- raise ParseError , exception . message
13+ rescue StandardError => e
14+ raise ParseError , e . message
1315 end
1416
1517 # :reek:DuplicateMethodCall { allow_calls: ['elements.shift', 'elements.first'] }
@@ -66,15 +68,16 @@ def initialize(id, version_string, params_string, encoded_salt, encoded_hash)
6668 end
6769
6870 def to_s
69- '$' + [
71+ "$ #{ [
7072 @id ,
7173 @version_string ,
7274 @params_string ,
7375 @encoded_salt ,
7476 @encoded_hash
75- ] . compact . join ( '$' )
77+ ] . compact . join ( '$' ) } "
7678 end
7779
80+ # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
7881 def to_h ( pick : nil , hint : { } )
7982 pick ||= %i[ id version params salt hash ]
8083 {
@@ -88,6 +91,7 @@ def to_h(pick: nil, hint: {})
8891 hash : ( B64 . decode ( @encoded_hash ) if pick . include? ( :hash ) )
8992 } . select { |_ , value | value }
9093 end
94+ # rubocop:enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
9195
9296 def ==( other )
9397 instance_variable_values = other . instance_variables . map { |name | other . instance_variable_get ( name ) }
@@ -116,7 +120,7 @@ def self.to_s(params)
116120
117121 def self . to_h ( params_string )
118122 params_string ||= ''
119- params_string
123+ params_string # rubocop:disable Style/HashTransformValues
120124 . split ( /,/ )
121125 . map { |param | param . split '=' }
122126 . map { |name , value | [ name , value =~ /\A -?\d +(.\d +)?\Z / ? value . to_i : value ] }
0 commit comments