<commit_before><?php

/**
 * NS System OS unit interface
 *
 * Copyright 2016-2019 秋水之冰 <<EMAIL>>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace core\lib\os;

/**
 * Interface unit
 *
 * @package core\lib\os
 */
interface unit
{
    /**
     * Get hardware hash value
     *
     * @return string
     */
    public function get_hw_hash(): string;

    /**
     * Get PHP executable path
     *
     * @return string
     */
    public function get_php_path(): string;

    /**
     * Set as background command
     *
     * @return $this
     */
    public function bg(): object;

    /**
     * Set command with ENV values
     *
     * @return $this
     */
    public function env(): object;

    /**
     * Set command for proc_* functions
     *
     * @return $this
     */
    public function proc(): object;
}<commit_msg>change os/unit from interface to abstract class<commit_after><?php

/**
 * NS System OS unit controller
 *
 * Copyright 2016-2019 秋水之冰 <<EMAIL>>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace core\lib\os;

/**
 * Interface unit
 *
 * @package core\lib\os
 */
abstract class unit
{
    /**
     * @var string OS command
     */
    protected $os_cmd = '';

    /**
     * Get hardware hash value
     *
     * @return string
     */
    abstract public function get_hw_hash(): string;

    /**
     * Get PHP executable path
     *
     * @return string
     */
    abstract public function get_php_path(): string;

    /**
     * Set as background command
     *
     * @return $this
     */
    abstract public function bg(): object;

    /**
     * Set command with ENV values
     *
     * @return $this
     */
    abstract public function env(): object;

    /**
     * Set command for proc_* functions
     *
     * @return $this
     */
    abstract public function proc(): object;

    /**
     * Set command
     *
     * @param string $cmd
     *
     * @return $this
     */
    public function cmd(string $cmd): object
    {
        $this->os_cmd = &$cmd;
        return $this;
    }

    /**
     * Fetch command
     *
     * @return string
     */
    public function fetch(): string
    {
        return $this->os_cmd;
    }

    /**
     * Execute unit command & capture outputs
     *
     * @param int $return_var
     *
     * @return array
     */
    public function execute(int &$return_var = 0): array
    {
        exec($this->os_cmd, $output, $return_var);
        return $output;
    }
}
{'fraction_non_alphanumeric': 0.10665137614678899, 'fraction_numerical': 0.007167431192660551, 'mean_word_length': 2.203856749311295, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3907338', 'n_tokens_mistral': 1005, 'n_tokens_neox': 974, 'n_words': 361}