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 | <?php |
||
| 14 | class Issuer extends NameIDType |
||
| 15 | { |
||
| 16 | |||
| 17 | /** |
||
| 18 | * The format of this NameIDType. |
||
| 19 | * |
||
| 20 | * Defaults to urn:oasis:names:tc:SAML:2.0:nameid-format:entity: |
||
| 21 | * |
||
| 22 | * Indicates that the content of the element is the identifier of an entity that provides SAML-based services (such |
||
| 23 | * as a SAML authority, requester, or responder) or is a participant in SAML profiles (such as a service provider |
||
| 24 | * supporting the browser SSO profile). Such an identifier can be used in the <Issuer> element to identify the |
||
| 25 | * issuer of a SAML request, response, or assertion, or within the <NameID> element to make assertions about system |
||
| 26 | * entities that can issue SAML requests, responses, and assertions. It can also be used in other elements and |
||
| 27 | * attributes whose purpose is to identify a system entity in various protocol exchanges. |
||
| 28 | * |
||
| 29 | * The syntax of such an identifier is a URI of not more than 1024 characters in length. It is RECOMMENDED that a |
||
| 30 | * system entity use a URL containing its own domain name to identify itself. |
||
| 31 | * |
||
| 32 | * @see saml-core-2.0-os |
||
| 33 | * |
||
| 34 | * @var string |
||
| 35 | */ |
||
| 36 | public $Format = Constants::NAMEID_ENTITY; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Set the name of this XML element to "saml:Issuer" |
||
| 40 | * |
||
| 41 | * @var string |
||
| 42 | */ |
||
| 43 | protected $nodeName = 'saml:Issuer'; |
||
| 44 | |||
| 45 | |||
| 46 | /** |
||
| 47 | * Convert this Issuer to XML. |
||
| 48 | * |
||
| 49 | * @param \DOMElement|null $parent The element we should append to. |
||
| 50 | * |
||
| 51 | * @return \DOMElement The current Issuer object converted into a \DOMElement. |
||
| 52 | */ |
||
| 53 | public function toXML(\DOMElement $parent = null) |
||
| 77 | } |
||
| 78 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.