• Skip to sidebar navigation
  • Skip to content

Bitbucket

  • More
    ProjectsRepositories
    • Help
      • Online help
      • Learn Git
      • Welcome to Bitbucket
      • Keyboard shortcuts
    • Log In
    Blackrock
    1. Blackrock

    main

    Public
    Actions
    • Clone

    Learn more about cloning repositories

    You have read-only access

    Navigation
    • Source
    • Commits
    • Branches
    • All Branches Graph
    • Graphs
    • Forks
    1. Blackrock
    2. main

    Source

    main/wp-content/plugins/wpml-translation-management/classes/translation-proxy/api/class-wpml-tp-api-request.php
    Артем ШиряевАртем Ширяев committed 554847ddcb906 Apr 2021
    Raw file
    Source viewDiff to previous
     
    1
    <?php
    2
    ​
    3
    class WPML_TP_API_Request {
    4
        const API_VERSION = 1.1;
    5
    ​
    6
        /** @var string */
    7
        private $url;
    8
    ​
    9
        /** @var array */
    10
        private $params = array( 'api_version' => self::API_VERSION );
    11
    ​
    12
        /** @var string */
    13
        private $method = 'GET';
    14
    ​
    15
        /** @var bool */
    16
        private $has_api_response = true;
    17
    ​
    18
        /**
    19
         * @param string $url
    20
         */
    21
        public function __construct( $url ) {
    22
            if ( empty( $url ) ) {
    23
                throw new InvalidArgumentException( 'Url cannot be empty' );
    24
            }
    25
            $this->url = $url;
    26
        }
    27
    ​
    28
        /**
    29
         * @param array $params
    30
         */
    31
        public function set_params( array $params ) {
    32
            $this->params = array_merge( $this->params, $params );
    33
        }
    34
    ​
    35
        /**
    36
         * @param string $method
    37
         */
    38
        public function set_method( $method ) {
    39
            if ( ! in_array( $method, array( 'GET', 'POST', 'PUT', 'DELETE', 'HEAD' ), true ) ) {
    40
                throw new InvalidArgumentException( 'HTTP request method has invalid value' );
    41
            }
    42
    ​
    43
            $this->method = $method;
    44
        }
    45
    ​
    46
        /**
    47
         * @param bool $has_api_response
    48
         */
    49
        public function set_has_api_response( $has_api_response ) {
    50
            $this->has_api_response = (bool) $has_api_response;
    51
        }
    52
    ​
    53
        /**
    54
         * @return string
    55
         */
    56
        public function get_url() {
    57
            $url = $this->url;
    58
            if ( $this->get_params() ) {
    59
                list( $url, $params_used_in_path ) = $this->add_parameters_to_path( $url, $this->get_params() );
    60
                if ( 'GET' === $this->get_method() ) {
    61
                    $url = $this->add_query_parameters( $params_used_in_path, $url );
    62
                }
    63
            }
    • Git repository management for enterprise teams powered by Atlassian Bitbucket
    • Atlassian Bitbucket v5.10.1
    • Documentation
    • Contact Support
    • Request a feature
    • About
    • Contact Atlassian
    Atlassian

    Everything looks good. Well let you know here if theres anything you should know about.