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:
Complex classes like Swift_Signers_DKIMSigner often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Swift_Signers_DKIMSigner, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 16 | class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner |
||
|
|
|||
| 17 | { |
||
| 18 | /** |
||
| 19 | * PrivateKey. |
||
| 20 | * |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | protected $_privateKey; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * DomainName. |
||
| 27 | * |
||
| 28 | * @var string |
||
| 29 | */ |
||
| 30 | protected $_domainName; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Selector. |
||
| 34 | * |
||
| 35 | * @var string |
||
| 36 | */ |
||
| 37 | protected $_selector; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Hash algorithm used. |
||
| 41 | * |
||
| 42 | * @var string |
||
| 43 | */ |
||
| 44 | protected $_hashAlgorithm = 'rsa-sha1'; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Body canon method. |
||
| 48 | * |
||
| 49 | * @var string |
||
| 50 | */ |
||
| 51 | protected $_bodyCanon = 'simple'; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Header canon method. |
||
| 55 | * |
||
| 56 | * @var string |
||
| 57 | */ |
||
| 58 | protected $_headerCanon = 'simple'; |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Headers not being signed. |
||
| 62 | * |
||
| 63 | * @var array |
||
| 64 | */ |
||
| 65 | protected $_ignoredHeaders = array('return-path' => true); |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Signer identity. |
||
| 69 | * |
||
| 70 | * @var string |
||
| 71 | */ |
||
| 72 | protected $_signerIdentity; |
||
| 73 | |||
| 74 | /** |
||
| 75 | * BodyLength. |
||
| 76 | * |
||
| 77 | * @var int |
||
| 78 | */ |
||
| 79 | protected $_bodyLen = 0; |
||
| 80 | |||
| 81 | /** |
||
| 82 | * Maximum signedLen. |
||
| 83 | * |
||
| 84 | * @var int |
||
| 85 | */ |
||
| 86 | protected $_maxLen = PHP_INT_MAX; |
||
| 87 | |||
| 88 | /** |
||
| 89 | * Embbed bodyLen in signature. |
||
| 90 | * |
||
| 91 | * @var bool |
||
| 92 | */ |
||
| 93 | protected $_showLen = false; |
||
| 94 | |||
| 95 | /** |
||
| 96 | * When the signature has been applied (true means time()), false means not embedded. |
||
| 97 | * |
||
| 98 | * @var mixed |
||
| 99 | */ |
||
| 100 | protected $_signatureTimestamp = true; |
||
| 101 | |||
| 102 | /** |
||
| 103 | * When will the signature expires false means not embedded, if sigTimestamp is auto |
||
| 104 | * Expiration is relative, otherwhise it's absolute. |
||
| 105 | * |
||
| 106 | * @var int |
||
| 107 | */ |
||
| 108 | protected $_signatureExpiration = false; |
||
| 109 | |||
| 110 | /** |
||
| 111 | * Must we embed signed headers? |
||
| 112 | * |
||
| 113 | * @var bool |
||
| 114 | */ |
||
| 115 | protected $_debugHeaders = false; |
||
| 116 | |||
| 117 | // work variables |
||
| 118 | /** |
||
| 119 | * Headers used to generate hash. |
||
| 120 | * |
||
| 121 | * @var array |
||
| 122 | */ |
||
| 123 | protected $_signedHeaders = array(); |
||
| 124 | |||
| 125 | /** |
||
| 126 | * If debugHeaders is set store debugDatas here. |
||
| 127 | * |
||
| 128 | * @var string |
||
| 129 | */ |
||
| 130 | private $_debugHeadersData = ''; |
||
| 131 | |||
| 132 | /** |
||
| 133 | * Stores the bodyHash. |
||
| 134 | * |
||
| 135 | * @var string |
||
| 136 | */ |
||
| 137 | private $_bodyHash = ''; |
||
| 138 | |||
| 139 | /** |
||
| 140 | * Stores the signature header. |
||
| 141 | * |
||
| 142 | * @var Swift_Mime_Headers_ParameterizedHeader |
||
| 143 | */ |
||
| 144 | protected $_dkimHeader; |
||
| 145 | |||
| 146 | /** |
||
| 147 | * @var resource |
||
| 148 | */ |
||
| 149 | private $_bodyHashHandler; |
||
| 150 | |||
| 151 | /** |
||
| 152 | * @var null |
||
| 153 | * |
||
| 154 | * no used? |
||
| 155 | */ |
||
| 156 | private $_headerHash; |
||
| 157 | |||
| 158 | /** |
||
| 159 | * @var string |
||
| 160 | */ |
||
| 161 | private $_headerCanonData = ''; |
||
| 162 | |||
| 163 | /** |
||
| 164 | * @var int |
||
| 165 | */ |
||
| 166 | private $_bodyCanonEmptyCounter = 0; |
||
| 167 | |||
| 168 | /** |
||
| 169 | * @var int |
||
| 170 | */ |
||
| 171 | private $_bodyCanonIgnoreStart = 2; |
||
| 172 | |||
| 173 | /** |
||
| 174 | * @var bool |
||
| 175 | */ |
||
| 176 | private $_bodyCanonSpace = false; |
||
| 177 | |||
| 178 | /** |
||
| 179 | * @var null|string |
||
| 180 | */ |
||
| 181 | private $_bodyCanonLastChar = null; |
||
| 182 | |||
| 183 | /** |
||
| 184 | * @var string |
||
| 185 | */ |
||
| 186 | private $_bodyCanonLine = ''; |
||
| 187 | |||
| 188 | /** |
||
| 189 | * @var array |
||
| 190 | */ |
||
| 191 | private $_bound = array(); |
||
| 192 | |||
| 193 | /** |
||
| 194 | * Constructor. |
||
| 195 | * |
||
| 196 | * @param string $privateKey |
||
| 197 | * @param string $domainName |
||
| 198 | * @param string $selector |
||
| 199 | */ |
||
| 200 | 1 | View Code Duplication | public function __construct($privateKey, $domainName, $selector) |
| 207 | |||
| 208 | /** |
||
| 209 | * Instanciate DKIMSigner. |
||
| 210 | * |
||
| 211 | * @param string $privateKey |
||
| 212 | * @param string $domainName |
||
| 213 | * @param string $selector |
||
| 214 | * |
||
| 215 | * @return Swift_Signers_DKIMSigner |
||
| 216 | */ |
||
| 217 | public static function newInstance($privateKey, $domainName, $selector) |
||
| 221 | |||
| 222 | /** |
||
| 223 | * Reset the Signer. |
||
| 224 | * |
||
| 225 | * @see Swift_Signer::reset() |
||
| 226 | */ |
||
| 227 | public function reset() |
||
| 228 | { |
||
| 229 | $this->_headerHash = null; |
||
| 230 | $this->_signedHeaders = array(); |
||
| 231 | $this->_bodyHash = null; |
||
| 232 | $this->_bodyHashHandler = null; |
||
| 233 | $this->_bodyCanonIgnoreStart = 2; |
||
| 234 | $this->_bodyCanonEmptyCounter = 0; |
||
| 235 | $this->_bodyCanonLastChar = null; |
||
| 236 | $this->_bodyCanonSpace = false; |
||
| 237 | } |
||
| 238 | |||
| 239 | /** |
||
| 240 | * Writes $bytes to the end of the stream. |
||
| 241 | * |
||
| 242 | * Writing may not happen immediately if the stream chooses to buffer. If |
||
| 243 | * you want to write these bytes with immediate effect, call {@link commit()} |
||
| 244 | * after calling write(). |
||
| 245 | * |
||
| 246 | * This method returns the sequence ID of the write (i.e. 1 for first, 2 for |
||
| 247 | * second, etc etc). |
||
| 248 | * |
||
| 249 | * @param string $bytes |
||
| 250 | * |
||
| 251 | * @throws Swift_IoException |
||
| 252 | * |
||
| 253 | * @return int |
||
| 254 | */ |
||
| 255 | public function write($bytes) |
||
| 256 | { |
||
| 257 | $this->_canonicalizeBody($bytes); |
||
| 258 | foreach ($this->_bound as $is) { |
||
| 259 | $is->write($bytes); |
||
| 260 | } |
||
| 261 | } |
||
| 262 | |||
| 263 | /** |
||
| 264 | * For any bytes that are currently buffered inside the stream, force them |
||
| 265 | * off the buffer. |
||
| 266 | * |
||
| 267 | * @throws Swift_IoException |
||
| 268 | */ |
||
| 269 | public function commit() |
||
| 274 | |||
| 275 | /** |
||
| 276 | * Attach $is to this stream. |
||
| 277 | * The stream acts as an observer, receiving all data that is written. |
||
| 278 | * All {@link write()} and {@link flushBuffers()} operations will be mirrored. |
||
| 279 | * |
||
| 280 | * @param Swift_InputByteStream $is |
||
| 281 | */ |
||
| 282 | public function bind(Swift_InputByteStream $is) |
||
| 289 | |||
| 290 | /** |
||
| 291 | * Remove an already bound stream. |
||
| 292 | * If $is is not bound, no errors will be raised. |
||
| 293 | * If the stream currently has any buffered data it will be written to $is |
||
| 294 | * before unbinding occurs. |
||
| 295 | * |
||
| 296 | * @param Swift_InputByteStream $is |
||
| 297 | */ |
||
| 298 | View Code Duplication | public function unbind(Swift_InputByteStream $is) |
|
| 299 | { |
||
| 300 | // Don't have to mirror anything |
||
| 301 | foreach ($this->_bound as $k => $stream) { |
||
| 302 | if ($stream === $is) { |
||
| 303 | unset($this->_bound[$k]); |
||
| 304 | |||
| 305 | return; |
||
| 306 | } |
||
| 307 | } |
||
| 308 | |||
| 309 | return; |
||
| 310 | } |
||
| 311 | |||
| 312 | /** |
||
| 313 | * Flush the contents of the stream (empty it) and set the internal pointer |
||
| 314 | * to the beginning. |
||
| 315 | * |
||
| 316 | * @throws Swift_IoException |
||
| 317 | */ |
||
| 318 | public function flushBuffers() |
||
| 322 | |||
| 323 | /** |
||
| 324 | * Set hash_algorithm, must be one of rsa-sha256 | rsa-sha1 defaults to rsa-sha256. |
||
| 325 | * |
||
| 326 | * @param string $hash |
||
| 327 | * |
||
| 328 | * @return Swift_Signers_DKIMSigner |
||
| 329 | */ |
||
| 330 | public function setHashAlgorithm($hash) |
||
| 331 | { |
||
| 332 | // Unable to sign with rsa-sha256 |
||
| 333 | if ($hash == 'rsa-sha1') { |
||
| 334 | $this->_hashAlgorithm = 'rsa-sha1'; |
||
| 335 | } else { |
||
| 336 | $this->_hashAlgorithm = 'rsa-sha256'; |
||
| 337 | } |
||
| 338 | |||
| 339 | return $this; |
||
| 340 | } |
||
| 341 | |||
| 342 | /** |
||
| 343 | * Set the body canonicalization algorithm. |
||
| 344 | * |
||
| 345 | * @param string $canon |
||
| 346 | * |
||
| 347 | * @return Swift_Signers_DKIMSigner |
||
| 348 | */ |
||
| 349 | public function setBodyCanon($canon) |
||
| 350 | { |
||
| 351 | if ($canon == 'relaxed') { |
||
| 352 | $this->_bodyCanon = 'relaxed'; |
||
| 353 | } else { |
||
| 354 | $this->_bodyCanon = 'simple'; |
||
| 355 | } |
||
| 356 | |||
| 357 | return $this; |
||
| 358 | } |
||
| 359 | |||
| 360 | /** |
||
| 361 | * Set the header canonicalization algorithm. |
||
| 362 | * |
||
| 363 | * @param string $canon |
||
| 364 | * |
||
| 365 | * @return Swift_Signers_DKIMSigner |
||
| 366 | */ |
||
| 367 | public function setHeaderCanon($canon) |
||
| 368 | { |
||
| 369 | if ($canon == 'relaxed') { |
||
| 370 | $this->_headerCanon = 'relaxed'; |
||
| 371 | } else { |
||
| 372 | $this->_headerCanon = 'simple'; |
||
| 373 | } |
||
| 374 | |||
| 375 | return $this; |
||
| 376 | } |
||
| 377 | |||
| 378 | /** |
||
| 379 | * Set the signer identity. |
||
| 380 | * |
||
| 381 | * @param string $identity |
||
| 382 | * |
||
| 383 | * @return Swift_Signers_DKIMSigner |
||
| 384 | */ |
||
| 385 | public function setSignerIdentity($identity) |
||
| 391 | |||
| 392 | /** |
||
| 393 | * Set the length of the body to sign. |
||
| 394 | * |
||
| 395 | * @param mixed $len (bool or int) |
||
| 396 | * |
||
| 397 | * @return Swift_Signers_DKIMSigner |
||
| 398 | */ |
||
| 399 | public function setBodySignedLen($len) |
||
| 400 | { |
||
| 401 | if ($len === true) { |
||
| 402 | $this->_showLen = true; |
||
| 403 | $this->_maxLen = PHP_INT_MAX; |
||
| 404 | } elseif ($len === false) { |
||
| 405 | $this->_showLen = false; |
||
| 406 | $this->_maxLen = PHP_INT_MAX; |
||
| 407 | } else { |
||
| 408 | $this->_showLen = true; |
||
| 409 | $this->_maxLen = (int) $len; |
||
| 410 | } |
||
| 411 | |||
| 412 | return $this; |
||
| 413 | } |
||
| 414 | |||
| 415 | /** |
||
| 416 | * Set the signature timestamp. |
||
| 417 | * |
||
| 418 | * @param int $time A timestamp |
||
| 419 | * |
||
| 420 | * @return Swift_Signers_DKIMSigner |
||
| 421 | */ |
||
| 422 | public function setSignatureTimestamp($time) |
||
| 423 | { |
||
| 424 | $this->_signatureTimestamp = $time; |
||
| 425 | |||
| 426 | return $this; |
||
| 427 | } |
||
| 428 | |||
| 429 | /** |
||
| 430 | * Set the signature expiration timestamp. |
||
| 431 | * |
||
| 432 | * @param int $time A timestamp |
||
| 433 | * |
||
| 434 | * @return Swift_Signers_DKIMSigner |
||
| 435 | */ |
||
| 436 | public function setSignatureExpiration($time) |
||
| 442 | |||
| 443 | /** |
||
| 444 | * Enable / disable the DebugHeaders. |
||
| 445 | * |
||
| 446 | * @param bool $debug |
||
| 447 | * |
||
| 448 | * @return Swift_Signers_DKIMSigner |
||
| 449 | */ |
||
| 450 | public function setDebugHeaders($debug) |
||
| 456 | |||
| 457 | /** |
||
| 458 | * Start Body. |
||
| 459 | */ |
||
| 460 | public function startBody() |
||
| 461 | { |
||
| 462 | // Init |
||
| 463 | switch ($this->_hashAlgorithm) { |
||
| 464 | case 'rsa-sha256' : |
||
| 465 | $this->_bodyHashHandler = hash_init('sha256'); |
||
| 466 | break; |
||
| 467 | case 'rsa-sha1' : |
||
| 468 | $this->_bodyHashHandler = hash_init('sha1'); |
||
| 469 | break; |
||
| 470 | } |
||
| 471 | $this->_bodyCanonLine = ''; |
||
| 472 | } |
||
| 473 | |||
| 474 | /** |
||
| 475 | * End Body. |
||
| 476 | */ |
||
| 477 | public function endBody() |
||
| 478 | { |
||
| 479 | $this->_endOfBody(); |
||
| 480 | } |
||
| 481 | |||
| 482 | /** |
||
| 483 | * Returns the list of Headers Tampered by this plugin. |
||
| 484 | * |
||
| 485 | * @return string[] |
||
| 486 | */ |
||
| 487 | public function getAlteredHeaders() |
||
| 488 | { |
||
| 489 | if ($this->_debugHeaders) { |
||
| 490 | return array('DKIM-Signature', 'X-DebugHash'); |
||
| 491 | } else { |
||
| 492 | return array('DKIM-Signature'); |
||
| 493 | } |
||
| 494 | } |
||
| 495 | |||
| 496 | /** |
||
| 497 | * Adds an ignored Header. |
||
| 498 | * |
||
| 499 | * @param string $header_name |
||
| 500 | * |
||
| 501 | * @return Swift_Signers_DKIMSigner |
||
| 502 | */ |
||
| 503 | public function ignoreHeader($header_name) |
||
| 509 | |||
| 510 | /** |
||
| 511 | * Set the headers to sign. |
||
| 512 | * |
||
| 513 | * @param Swift_Mime_HeaderSet $headers |
||
| 514 | * |
||
| 515 | * @return Swift_Signers_DKIMSigner |
||
| 516 | */ |
||
| 517 | View Code Duplication | public function setHeaders(Swift_Mime_HeaderSet $headers) |
|
| 518 | { |
||
| 519 | $this->_headerCanonData = ''; |
||
| 520 | // Loop through Headers |
||
| 521 | $listHeaders = $headers->listAll(); |
||
| 522 | foreach ($listHeaders as $hName) { |
||
| 523 | // Check if we need to ignore Header |
||
| 524 | if (!isset($this->_ignoredHeaders[Swift::strtolowerWithStaticCache($hName)])) { |
||
| 525 | if ($headers->has($hName)) { |
||
| 526 | $tmp = $headers->getAll($hName); |
||
| 527 | foreach ($tmp as $header) { |
||
| 528 | if ($header->getFieldBody() != '') { |
||
| 529 | $this->_addHeader($header->toString()); |
||
| 530 | $this->_signedHeaders[] = $header->getFieldName(); |
||
| 531 | } |
||
| 532 | } |
||
| 533 | } |
||
| 534 | } |
||
| 535 | } |
||
| 536 | |||
| 537 | return $this; |
||
| 538 | } |
||
| 539 | |||
| 540 | /** |
||
| 541 | * Add the signature to the given Headers. |
||
| 542 | * |
||
| 543 | * @param Swift_Mime_HeaderSet $headers |
||
| 544 | * |
||
| 545 | * @return Swift_Signers_DKIMSigner |
||
| 546 | */ |
||
| 547 | public function addSignature(Swift_Mime_HeaderSet $headers) |
||
| 548 | { |
||
| 549 | // Prepare the DKIM-Signature |
||
| 550 | $params = array('v' => '1', 'a' => $this->_hashAlgorithm, 'bh' => base64_encode($this->_bodyHash), 'd' => $this->_domainName, 'h' => implode(': ', $this->_signedHeaders), 'i' => $this->_signerIdentity, 's' => $this->_selector); |
||
| 551 | if ($this->_bodyCanon != 'simple') { |
||
| 552 | $params['c'] = $this->_headerCanon . '/' . $this->_bodyCanon; |
||
| 553 | } elseif ($this->_headerCanon != 'simple') { |
||
| 554 | $params['c'] = $this->_headerCanon; |
||
| 555 | } |
||
| 556 | if ($this->_showLen) { |
||
| 557 | $params['l'] = $this->_bodyLen; |
||
| 558 | } |
||
| 559 | if ($this->_signatureTimestamp === true) { |
||
| 560 | $params['t'] = time(); |
||
| 561 | if ($this->_signatureExpiration !== false) { |
||
| 562 | $params['x'] = $params['t'] + $this->_signatureExpiration; |
||
| 563 | } |
||
| 564 | } else { |
||
| 565 | if ($this->_signatureTimestamp !== false) { |
||
| 566 | $params['t'] = $this->_signatureTimestamp; |
||
| 567 | } |
||
| 568 | if ($this->_signatureExpiration !== false) { |
||
| 569 | $params['x'] = $this->_signatureExpiration; |
||
| 570 | } |
||
| 571 | } |
||
| 572 | if ($this->_debugHeaders) { |
||
| 573 | $params['z'] = implode('|', $this->_debugHeadersData); |
||
| 574 | } |
||
| 575 | $string = ''; |
||
| 576 | foreach ($params as $k => $v) { |
||
| 577 | $string .= $k . '=' . $v . '; '; |
||
| 578 | } |
||
| 579 | $string = trim($string); |
||
| 580 | $headers->addTextHeader('DKIM-Signature', $string); |
||
| 581 | // Add the last DKIM-Signature |
||
| 582 | $tmp = $headers->getAll('DKIM-Signature'); |
||
| 583 | $this->_dkimHeader = end($tmp); |
||
| 584 | $this->_addHeader(trim($this->_dkimHeader->toString()) . "\r\n b=", true); |
||
| 585 | $this->_endOfHeaders(); |
||
| 586 | if ($this->_debugHeaders) { |
||
| 587 | $headers->addTextHeader('X-DebugHash', base64_encode($this->_headerHash)); |
||
| 588 | } |
||
| 589 | $this->_dkimHeader->setValue($string . ' b=' . trim(chunk_split(base64_encode($this->_getEncryptedHash()), 73, ' '))); |
||
| 590 | |||
| 591 | return $this; |
||
| 592 | } |
||
| 593 | |||
| 594 | /* Private helpers */ |
||
| 595 | |||
| 596 | View Code Duplication | protected function _addHeader($header, $is_sig = false) |
|
| 597 | { |
||
| 598 | switch ($this->_headerCanon) { |
||
| 599 | case 'relaxed' : |
||
| 600 | // Prepare Header and cascade |
||
| 601 | $exploded = explode(':', $header, 2); |
||
| 602 | $name = Swift::strtolowerWithStaticCache(trim($exploded[0])); |
||
| 603 | $value = str_replace("\r\n", '', $exploded[1]); |
||
| 604 | $value = preg_replace("/[ \t][ \t]+/", ' ', $value); |
||
| 605 | $header = $name . ':' . trim($value) . ($is_sig ? '' : "\r\n"); |
||
| 606 | case 'simple' : |
||
| 607 | // Nothing to do |
||
| 608 | } |
||
| 609 | $this->_addToHeaderHash($header); |
||
| 610 | } |
||
| 611 | |||
| 612 | /** |
||
| 613 | * @deprecated This method is currently useless in this class but it must be |
||
| 614 | * kept for BC reasons due to its "protected" scope. This method |
||
| 615 | * might be overriden by custom client code. |
||
| 616 | */ |
||
| 617 | protected function _endOfHeaders() |
||
| 620 | |||
| 621 | protected function _canonicalizeBody($string) |
||
| 622 | { |
||
| 623 | $len = strlen($string); |
||
| 624 | $canon = ''; |
||
| 625 | $method = ($this->_bodyCanon == 'relaxed'); |
||
| 626 | for ($i = 0; $i < $len; ++$i) { |
||
| 627 | if ($this->_bodyCanonIgnoreStart > 0) { |
||
| 628 | --$this->_bodyCanonIgnoreStart; |
||
| 629 | continue; |
||
| 630 | } |
||
| 631 | switch ($string[$i]) { |
||
| 632 | case "\r" : |
||
| 633 | $this->_bodyCanonLastChar = "\r"; |
||
| 634 | break; |
||
| 673 | |||
| 674 | protected function _endOfBody() |
||
| 683 | |||
| 684 | /** |
||
| 685 | * @param string $string |
||
| 686 | */ |
||
| 687 | private function _addToBodyHash($string) |
||
| 697 | |||
| 698 | private function _addToHeaderHash($header) |
||
| 705 | |||
| 706 | /** |
||
| 707 | * @throws Swift_SwiftException |
||
| 708 | * |
||
| 709 | * @return string |
||
| 710 | */ |
||
| 711 | private function _getEncryptedHash() |
||
| 731 | } |
||
| 732 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.