Completed
Push — master ( 330dad...b4ceb2 )
by
unknown
12s queued 10s
created

SubscriptionListResponse   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 70.59 %

Importance

Changes 0
Metric Value
dl 24
loc 34
rs 10
c 0
b 0
f 0
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A subscription_details() 12 12 3
A initialize() 12 12 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
module AuthorizeNet::ARB
2
  class SubscriptionListResponse < AuthorizeNet::XmlResponse
3
    # Constructs a new response object from a +raw_response. You don't typically
4
    # construct this object yourself, as AuthorizeNet::ARB::Transaction will
5
    # build one for you when it makes the request to the gateway.
6 View Code Duplication
    def initialize(raw_response, transaction)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7
      super
8
      unless connection_failure?
9
        begin
10
          @subscription_details = @root.at_css('subscriptionDetails')
11
          @subscription_detail = @root.at_css('subscriptionDetail')
12
          @total_num_in_resultset = node_content_unless_nil(@root.at_css('totalNumInResultSet'))
13
        rescue StandardError
14
          @raw_response = $ERROR_INFO
15
        end
16
      end
17
    end
18
19
    # Returns total number of subscriptions matching the search criteria
20
    attr_reader :total_num_in_resultset
21
22
    # Returns an Array of SubscriptionDetail objects built from the entities returned in the response. Returns nil if no subscriptions were returned.
23 View Code Duplication
    def subscription_details
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
24
      unless @subscription_details.nil?
25
        subscription_details = []
26
        @subscription_details.element_children.each do |child|
27
          next if child.nil?
28
          subscription_detail = build_entity(child, Fields::SUBSCRIPTION_DETAIL_ENTITY_DESCRIPTION)
29
30
          subscription_details <<= subscription_detail
31
        end
32
        return subscription_details unless subscription_details.empty?
33
       end
34
    end
35
  end
36
end
37