HEX
Server: Apache/2
System: Linux vps33975.sdns.vn 3.10.0-1160.15.2.el7.x86_64 #1 SMP Wed Feb 3 15:06:38 UTC 2021 x86_64
User: agritom (1060)
PHP: 7.4.33
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/agritom/public_html/wp-content/plugins/loco-translate/src/gettext/String.php
<?php
/**
 * Gettext source string. Does not contain translations.
 */
class Loco_gettext_String {

    /**
     * @var array
     */
    private $raw;

    /**
     * @var string
     */
    private $plural;
    

    /**
     * Loco_gettext_String constructor.
     *
     * @param string Mandatory source
     * @param string Optional context
     */
    public function __construct( $msgid, $msgctxt = '' ){
        $this->raw =  [
            'source' => (string) $msgid,
            'context' => (string) $msgctxt,
        ];
    }


    /**
     * Get singular form as raw array data
     * @internal
     * @return string[]
     */
    public function exportSingular(){
        return $this->raw;
    }


    /**
     * Get plural form as raw array data
     * @internal
     * @return string[]
     */
    public function exportPlural(){
        return  [
            'source' => $this->plural,
        ];
    }


    /**
     * @param string
     * @param string|array
     * @param string
     * @return void
     */
    private function merge( $prop, $value, $glue ){
        if( is_string($value) ){
            $value = [$value];
        }
        else if( ! is_array($value) ){
            throw new InvalidArgumentException('Expected Array or String');
        }
        if( array_key_exists($prop,$this->raw) ){
            $value = array_merge( explode($glue,$this->raw[$prop]), $value );
        }
        $this->raw[$prop] = implode($glue,$value);
    }


    /**
     * @param array|string
     * @return self
     */
    public function addFileReferences( $refs ){
        $this->merge('refs',$refs,' ');
        return $this;
    }


    /**
     * @param array|string
     * @return self
     */
    public function addExtractedComment( $notes ){
        $this->merge('notes',$notes,' ');
        return $this;
    }

    /**
     * @param string
     * @return self
     */
    public function pluralize( $msgid_plural ){
        $this->plural = (string) $msgid_plural;
        return $this;
    }


    /**
     * @return bool
     */
    public function hasPlural(){
        return is_string($this->plural) && '' !== $this->plural;
    }

}