original_string: public function setAtomLink($href, $rel = null, $type = null, $hreflang = null, $title = null, $length = null)
      {
          $data = array('href' => $href);
  
          if ($rel != null) {
              if (!is_string($rel) || empty($rel))
                  throw new \InvalidArgumentException('rel parameter must be a string and a valid relation identifier.');
  
              $data['rel'] = $rel;
          }
          if ($type != null) {
              // Regex used from RFC 4287, page 41
              if (!is_string($type) || preg_match('/.+\/.+/', $type) != 1)
                  throw new \InvalidArgumentException('type parameter must be a string and a MIME type.');
  
              $data['type'] = $type;
          }
          if ($hreflang != null) {
              // Regex used from RFC 4287, page 41
              if (!is_string($hreflang) || preg_match('/[A-Za-z]{1,8}(-[A-Za-z0-9]{1,8})*/', $hreflang) != 1)
                  throw new \InvalidArgumentException('hreflang parameter must be a string and a valid language code.');
  
              $data['hreflang'] = $hreflang;
          }
          if ($title != null) {
              if (!is_string($title) || empty($title))
                  throw new \InvalidArgumentException('title parameter must be a string and not empty.');
  
              $data['title'] = $title;
          }
          if ($length != null) {
              if (!is_int($length) || $length < 0)
                  throw new \InvalidArgumentException('length parameter must be a positive integer.');
  
              $data['length'] = (string) $length;
          }
  
          // ATOM spec. has some restrictions on atom:link usage
          // See RFC 4287, page 12 (4.1.1)
          if ($this->version == Feed::ATOM) {
              foreach ($this->channels as $key => $value) {
                  if ($key != 'atom:link')
                      continue;
  
                  // $value is an array , so check every element
                  foreach ($value as $linkItem) {
                      $attrib = $linkItem['attributes'];
                      // Only one link with relation alternate and same hreflang & type is allowed.
                      if (@$attrib['rel'] == 'alternate' && @$attrib['hreflang'] == $hreflang && @$attrib['type'] == $type)
                          throw new InvalidOperationException('The feed must not contain more than one link element with a'
                          . ' relation of "alternate" that has the same combination of type and hreflang attribute values.');
                  }
              }
          }
  
          return $this->setChannelElement('atom:link', '', $data, true);
      }
code: public function setAtomLink($href, $rel = null, $type = null, $hreflang = null, $title = null, $length = null)
      {
          $data = array('href' => $href);
  
          if ($rel != null) {
              if (!is_string($rel) || empty($rel))
                  throw new \InvalidArgumentException('rel parameter must be a string and a valid relation identifier.');
  
              $data['rel'] = $rel;
          }
          if ($type != null) {
              // Regex used from RFC 4287, page 41
              if (!is_string($type) || preg_match('/.+\/.+/', $type) != 1)
                  throw new \InvalidArgumentException('type parameter must be a string and a MIME type.');
  
              $data['type'] = $type;
          }
          if ($hreflang != null) {
              // Regex used from RFC 4287, page 41
              if (!is_string($hreflang) || preg_match('/[A-Za-z]{1,8}(-[A-Za-z0-9]{1,8})*/', $hreflang) != 1)
                  throw new \InvalidArgumentException('hreflang parameter must be a string and a valid language code.');
  
              $data['hreflang'] = $hreflang;
          }
          if ($title != null) {
              if (!is_string($title) || empty($title))
                  throw new \InvalidArgumentException('title parameter must be a string and not empty.');
  
              $data['title'] = $title;
          }
          if ($length != null) {
              if (!is_int($length) || $length < 0)
                  throw new \InvalidArgumentException('length parameter must be a positive integer.');
  
              $data['length'] = (string) $length;
          }
  
          // ATOM spec. has some restrictions on atom:link usage
          // See RFC 4287, page 12 (4.1.1)
          if ($this->version == Feed::ATOM) {
              foreach ($this->channels as $key => $value) {
                  if ($key != 'atom:link')
                      continue;
  
                  // $value is an array , so check every element
                  foreach ($value as $linkItem) {
                      $attrib = $linkItem['attributes'];
                      // Only one link with relation alternate and same hreflang & type is allowed.
                      if (@$attrib['rel'] == 'alternate' && @$attrib['hreflang'] == $hreflang && @$attrib['type'] == $type)
                          throw new InvalidOperationException('The feed must not contain more than one link element with a'
                          . ' relation of "alternate" that has the same combination of type and hreflang attribute values.');
                  }
              }
          }
  
          return $this->setChannelElement('atom:link', '', $data, true);
      }
code_tokens: public function setAtomLink ( $ href , $ rel = null , $ type = null , $ hreflang = null , $ title = null , $ length = null ) { $ data = array ( 'href' => $ href ) ; if ( $ rel != null ) { if ( ! is_string ( $ rel ) || empty ( $ rel ) ) throw new \ InvalidArgumentException ( 'rel parameter must be a string and a valid relation identifier.' ) ; $ data [ 'rel' ] = $ rel ; } if ( $ type != null ) { // Regex used from RFC 4287, page 41 if ( ! is_string ( $ type ) || preg_match ( '/.+\/.+/' , $ type ) != 1 ) throw new \ InvalidArgumentException ( 'type parameter must be a string and a MIME type.' ) ; $ data [ 'type' ] = $ type ; } if ( $ hreflang != null ) { // Regex used from RFC 4287, page 41 if ( ! is_string ( $ hreflang ) || preg_match ( '/[A-Za-z]{1,8}(-[A-Za-z0-9]{1,8})*/' , $ hreflang ) != 1 ) throw new \ InvalidArgumentException ( 'hreflang parameter must be a string and a valid language code.' ) ; $ data [ 'hreflang' ] = $ hreflang ; } if ( $ title != null ) { if ( ! is_string ( $ title ) || empty ( $ title ) ) throw new \ InvalidArgumentException ( 'title parameter must be a string and not empty.' ) ; $ data [ 'title' ] = $ title ; } if ( $ length != null ) { if ( ! is_int ( $ length ) || $ length < 0 ) throw new \ InvalidArgumentException ( 'length parameter must be a positive integer.' ) ; $ data [ 'length' ] = ( string ) $ length ; } // ATOM spec. has some restrictions on atom:link usage // See RFC 4287, page 12 (4.1.1) if ( $ this -> version == Feed :: ATOM ) { foreach ( $ this -> channels as $ key => $ value ) { if ( $ key != 'atom:link' ) continue ; // $value is an array , so check every element foreach ( $ value as $ linkItem ) { $ attrib = $ linkItem [ 'attributes' ] ; // Only one link with relation alternate and same hreflang & type is allowed. if ( @ $ attrib [ 'rel' ] == 'alternate' && @ $ attrib [ 'hreflang' ] == $ hreflang && @ $ attrib [ 'type' ] == $ type ) throw new InvalidOperationException ( 'The feed must not contain more than one link element with a' . ' relation of "alternate" that has the same combination of type and hreflang attribute values.' ) ; } } } return $ this -> setChannelElement ( 'atom:link' , '' , $ data , true ) ; }
docstring: Set custom 'link' channel elements.
  
  In ATOM feeds, only one link with alternate relation and the same combination of
  type and hreflang values.
  
  @access   public
  @param    string $href     URI of this link
  @param    string $rel      relation type of the resource
  @param    string $type     MIME type of the target resource
  @param    string $hreflang language of the resource
  @param    string $title    human-readable information about the resource
  @param    int    $length   length of the resource in bytes
  @link     https://www.iana.org/assignments/link-relations/link-relations.xml
  @link     https://tools.ietf.org/html/rfc4287#section-4.2.7
  @return   self
  @throws   \InvalidArgumentException on multiple occasions.
  @throws   InvalidOperationException if the same link with the same attributes was already added to the feed.
docstring_tokens: Set custom link channel elements .