<commit_before>//
//  Autolayout+Size.swift
//  LayoutHelper
//
//  Created by <NAME> on 8.8.2017.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import UIKit

public extension Autolayout {

  @discardableResult
  public func aspectRatio(
    ratio: CGFloat,
    priority: UILayoutPriority = UILayoutPriorityRequired,
    identifier: String? = nil
  ) -> NSLayoutConstraint {
    let _identifier = identifier.map { "(\($0))" } ?? ""
    let constraint = view.widthAnchor.constraint(equalTo: view.heightAnchor, multiplier: ratio)
    constraint.priority = priority
    constraint.identifier = "aspectRatio\(_identifier)"
    constraint.isActive = true
    return constraint
  }

  @discardableResult
  public func size(
    to size: CGSize,
    priority: UILayoutPriority = UILayoutPriorityRequired,
    identifier: String? = nil
  ) -> AxialConstraintSet {
    let sizeSet = AxialConstraintSet(
      horizontal: width(to: size.width, priority: priority),
      vertical: height(to: size.height, priority: priority)
    )

    let _identifier = identifier.map { "(\($0))" } ?? ""
    sizeSet.horizontal.identifier = "size.width\(_identifier)"
    sizeSet.vertical.identifier = "size.height\(_identifier)"

    return sizeSet
  }

  @discardableResult
  public func width(
    to constant: CGFloat,
    priority: UILayoutPriority = UILayoutPriorityRequired,
    identifier: String? = nil
  ) -> NSLayoutConstraint {
    let _identifier = identifier.map { "(\($0))" } ?? ""
    let constraint = view.widthAnchor.constraint(equalToConstant: constant)
    constraint.priority = priority
    constraint.identifier = "width\(_identifier)"
    constraint.isActive = true
    return constraint
  }

  @discardableResult
  public func height(
    to constant: CGFloat,
    priority: UILayoutPriority = UILayoutPriorityRequired,
    identifier: String? = nil
  ) -> NSLayoutConstraint {
    let _identifier = identifier.map { "(\($0))" } ?? ""
    let constraint = view.heightAnchor.constraint(equalToConstant: constant)
    constraint.priority = priority
    constraint.identifier = "height\(_identifier)"
    constraint.isActive = true
    return constraint
  }

}<commit_msg>Min and max size constraints<commit_after>//
//  Autolayout+Size.swift
//  LayoutHelper
//
//  Created by <NAME> on 8.8.2017.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import UIKit

public extension Autolayout {

  @discardableResult
  public func aspectRatio(
    ratio: CGFloat,
    priority: UILayoutPriority = UILayoutPriorityRequired,
    identifier: String? = nil
  ) -> NSLayoutConstraint {
    let _identifier = identifier.map { "(\($0))" } ?? ""
    let constraint = view.widthAnchor.constraint(equalTo: view.heightAnchor, multiplier: ratio)
    constraint.priority = priority
    constraint.identifier = "aspectRatio\(_identifier)"
    constraint.isActive = true
    return constraint
  }

  @discardableResult
  public func size(
    to size: CGSize,
    priority: UILayoutPriority = UILayoutPriorityRequired,
    identifier: String? = nil
  ) -> AxialConstraintSet {
    let sizeSet = AxialConstraintSet(
      horizontal: width(to: size.width, priority: priority),
      vertical: height(to: size.height, priority: priority)
    )

    let _identifier = identifier.map { "(\($0))" } ?? ""
    sizeSet.horizontal.identifier = "size.width\(_identifier)"
    sizeSet.vertical.identifier = "size.height\(_identifier)"

    return sizeSet
  }

  @discardableResult
  public func width(
    to constant: CGFloat,
    priority: UILayoutPriority = UILayoutPriorityRequired,
    identifier: String? = nil
  ) -> NSLayoutConstraint {
    let _identifier = identifier.map { "(\($0))" } ?? ""
    let constraint = view.widthAnchor.constraint(equalToConstant: constant)
    constraint.priority = priority
    constraint.identifier = "width\(_identifier)"
    constraint.isActive = true
    return constraint
  }

  @discardableResult
  public func minWidth(
    to constant: CGFloat,
    priority: UILayoutPriority = UILayoutPriorityRequired,
    identifier: String? = nil
  ) -> NSLayoutConstraint {
    let _identifier = identifier.map { "(\($0))" } ?? ""
    let constraint = view.widthAnchor.constraint(greaterThanOrEqualToConstant: constant)
    constraint.priority = priority
    constraint.identifier = "width\(_identifier)"
    constraint.isActive = true
    return constraint
  }

  @discardableResult
  public func maxWidth(
    to constant: CGFloat,
    priority: UILayoutPriority = UILayoutPriorityRequired,
    identifier: String? = nil
  ) -> NSLayoutConstraint {
    let _identifier = identifier.map { "(\($0))" } ?? ""
    let constraint = view.widthAnchor.constraint(lessThanOrEqualToConstant: constant)
    constraint.priority = priority
    constraint.identifier = "width\(_identifier)"
    constraint.isActive = true
    return constraint
  }

  @discardableResult
  public func height(
    to constant: CGFloat,
    priority: UILayoutPriority = UILayoutPriorityRequired,
    identifier: String? = nil
  ) -> NSLayoutConstraint {
    let _identifier = identifier.map { "(\($0))" } ?? ""
    let constraint = view.heightAnchor.constraint(equalToConstant: constant)
    constraint.priority = priority
    constraint.identifier = "height\(_identifier)"
    constraint.isActive = true
    return constraint
  }

  @discardableResult
  public func minHeight(
    to constant: CGFloat,
    priority: UILayoutPriority = UILayoutPriorityRequired,
    identifier: String? = nil
  ) -> NSLayoutConstraint {
    let _identifier = identifier.map { "(\($0))" } ?? ""
    let constraint = view.heightAnchor.constraint(greaterThanOrEqualToConstant: constant)
    constraint.priority = priority
    constraint.identifier = "height\(_identifier)"
    constraint.isActive = true
    return constraint
  }

  @discardableResult
  public func maxHeight(
    to constant: CGFloat,
    priority: UILayoutPriority = UILayoutPriorityRequired,
    identifier: String? = nil
  ) -> NSLayoutConstraint {
    let _identifier = identifier.map { "(\($0))" } ?? ""
    let constraint = view.heightAnchor.constraint(lessThanOrEqualToConstant: constant)
    constraint.priority = priority
    constraint.identifier = "height\(_identifier)"
    constraint.isActive = true
    return constraint
  }

}
{'fraction_non_alphanumeric': 0.10871991072851905, 'fraction_numerical': 0.005101227482863064, 'mean_word_length': 3.6302583025830257, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5375721', 'n_tokens_mistral': 1777, 'n_tokens_neox': 1739, 'n_words': 420}