PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of ASCOOS CMS   TEconomicsHandler   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: TEconomicsHandler
Perform several types of economic calculations
Author: By
Last change: Initial
Date: 19 days ago
Size: 24,595 bytes
 

Contents

Class file image Download

Class TEconomicsHandler

*This Ascoos Framework class handles arrays with economics formulas...*

Extends TArrayHandler

Construct :

    /
     * The constructor method for the class. It must always be overridden.
     * 
     * @desc <English>  Initializes the class with an array and optional properties.
     * @desc <Greek>    ??????????? ??? ????? ?? ???? ?????? ??? ???????????? ?????????.
     * 
     * @param array $array <English>  The array to initialize the class with.
     *                      <Greek>    ? ??????? ??? ??? ???????????? ??? ??????.
     * @param array $properties <English>  Optional properties for the class.
     *                           <Greek>    ???????????? ????????? ??? ??? ?????.
     * 
     * @version 25.0.0
     */
    public function __construct(array $array = [], array $properties = [])

Use:

/*
<English> Example 1: Earnings per share (EPS) calculation
<Greek> ?????????? 1: ??????????? ?????? ??? ?????? (EPS)
*/
use ASCOOS\FRAMEWORK\Extras\Economics\TEconomicsHandler;

/*
<English> Data
<Greek> ????????
*/
$array = [
    'net_income' => 500000, // Net income
    'number_of_shares' => 10000 // Number of shares
];

/*
<English> Create an object
<Greek> ?????????? ????????????
*/
$objEconomic = new TEconomicsHandler($array, ['decimals' => 2]);

/*
<English> EPS calculation
<Greek> ??????????? EPS
*/
$eps = $objEconomic->earnings_per_share();
echo "Earnings per share (EPS): $eps"._LN;

$objEconomic->Free($objEconomic);  

*

Array Parameters

float|int|null $fixed_cost = $this->array['fixed_cost'] // Fixed cost
float|int|null $variable_cost_per_unit = $this->array['variable_cost_per_unit'] // Variable cost per unit
float|int|null $quantity = $this->array['quantity'] // Quantity
float|int|null $current_assets = $this->array['current_assets'] // Current assets
float|int|null $current_liabilities = $this->array['current_liabilities'] // Current liabilities
float|int|null $total_liabilities = $this->array['total_liabilities'] // Total liabilities
float|int|null $shareholders_equity = $this->array['shareholders_equity'] // Shareholders' equity
float|int|null $net_income = $this->array['net_income'] // Net income
float|int|null $number_of_shares = $this->array['number_of_shares'] // Number of shares
float|int|null $gross_profit = $this->array['gross_profit'] // Gross profit
float|int|null $net_sales = $this->array['net_sales'] // Net sales
float|int|null $operating_profit = $this->array['operating_profit'] // Operating profit
float|int|null $administrative_expenses = $this->array['administrative_expenses'] // Administrative expenses
float|int|null $operational_expenses = $this->array['operational_expenses'] // Operational expenses
float|int|null $sales_expenses = $this->array['sales_expenses'] // Sales expenses
float|int|null $depreciation_expenses = $this->array['depreciation_expenses'] // Depreciation expenses
float|int|null $share_price = $this->array['share_price'] // Share price
float|int|null $dividends_per_share = $this->array['dividends_per_share'] // Dividends per share
float|int|null $total_equity = $this->array['total_equity'] // Total equity
float|int|null $ebit = $this->array['ebit'] // Earnings before interest and taxes (EBIT)
float|int|null $interest_expense = $this->array['interest_expense'] // Interest expense
float|int|null $total_revenue = $this->array['total_revenue'] // Total revenue
float|int|null $investment_cost = $this->array['investment_cost'] // Investment cost
float|int|null $beginning_inventory = $this->array['beginning_inventory'] // Beginning inventory
float|int|null $purchases = $this->array['purchases'] // Purchases
float|int|null $ending_inventory = $this->array['ending_inventory'] // Ending inventory
float|int|null $working_capital = $this->array['working_capital'] // Working capital
float|int|null $operating_cash_flow = $this->array['operating_cash_flow'] // Operating cash flow
float|int|null $capital_expenditure = $this->array['capital_expenditure'] // Capital expenditure
float|int|null $current_gdp = $this->array['current_gdp'] // Current GDP
float|int|null $previous_gdp = $this->array['previous_gdp'] // Previous GDP
float|int|null $cost_of_goods_sold = $this->array['cost_of_goods_sold'] // Cost of goods sold
float|int|null $average_inventory = $this->array['average_inventory'] // Average inventory
float|int|null $cash_flow = $this->array['cash_flow'] // Cash flow
float|int|null $discount_rate = $this->array['discount_rate'] // Discount rate
float|int|null $retained_earnings = $this->array['retained_earnings'] // Retained earnings
float|int|null $market_value_of_equity = $this->array['market_value_of_equity'] // Market value of equity
float|int|null $total_assets = $this->array['total_assets'] // Total assets
float|int|null $total_dividends = $this->array['total_dividends'] // Total dividends
float|int|null $initial_investment = $this->array['initial_investment'] // Initial investment
float|int|null $annual_cash_flows = $this->array['annual_cash_flows'] // Annual cash flows
float|int|null $randd_expenses = $this->array['randd_expenses'] // Research and development expenses
float|int|null $risk_free_rate = $this->array['risk_free_rate'] // Risk-free rate
float|int|null $beta = $this->array['beta'] // Beta
float|int|null $market_return = $this->array['market_return'] // Market return
float|int|null $present_value_of_cash_flows = $this->array['present_value_of_cash_flows'] // Present value of cash flows
float|int|null $sales = $this->array['sales'] // Sales
float|int|null $capital = $this->array['capital'] // Capital
float|int|null $wacc = $this->array['wacc'] // Weighted average cost of capital
float|int|null $net_operating_profit_after_taxes = $this->array['net_operating_profit_after_taxes'] // Net operating profit after taxes (NOPAT)
float|int|null $capital_employed = $this->array['capital_employed'] // Capital employed

methods

void __construct(array $array = [], array $properties = []) // The constructor method for the class. It must always be overridden.
float|int altman_z_score(float|int|null $working_capital, float|int|null $retained_earnings, float|int|null $ebit, float|int|null $market_value_of_equity, float|int|null $total_assets, float|int|null $total_liabilities)  // Calculate the Altman Z-Score based on various financial metrics.
float|int asset_turnover_ratio(float|int|null $net_sales, float|int|null $average_assets) // Calculate the asset turnover ratio based on net sales and average assets.
float|int capital_adequacy_ratio(float|int|null $equity, float|int|null $total_risk) // Calculate the capital adequacy ratio based on equity and total risk.
float|int capital_expenditure(float|int|null $purchase_of_fixed_assets, float|int|null $improvements_of_fixed_assets) // Calculate the capital expenditure based on the purchase of fixed assets and improvements of fixed assets.
float|int cash_conversion_cycle(float|int|null $inventory_period, float|int|null $receivables_period, float|int|null $payables_period) // Calculate the cash conversion cycle based on inventory period, receivables period, and payables period.
float|int cogs(float|int|null $beginning_inventory, float|int|null $purchases, float|int|null $ending_inventory) // Calculate the cost of goods sold (COGS) based on beginning inventory, purchases, and ending inventory.
float|int cost(float|int|null $fixed_cost, float|int|null $variable_cost_per_unit, float|int|null $quantity)    // Calculate the total cost based on fixed and variable costs.
float|int cost_of_equity(float|int|null $risk_free_rate, float|int|null $beta, float|int|null $market_return) // Calculate the cost of equity based on the risk-free rate, beta, and market return.
float|int current_ratio(float|int|null $current_assets, float|int|null $current_liabilities)                  // Calculate the current ratio based on current assets and current liabilities.
float|int current_yield(float|int|null $annual_interest, float|int|null $current_bond_price, int|null $decimals = null) // Calculate the current yield based on annual interest and current bond price.
float|int debt_ratio(float|int|null $total_liabilities, float|int|null $total_assets) // Calculate the debt ratio based on total liabilities and total assets.
float|int debt_service_coverage_ratio(float|int|null $net_operating_income, float|int|null $total_debt_service) // Calculate the debt service coverage ratio (DSCR) based on net operating income and total debt service.
float|int debt_to_equity_ratio(float|int|null $total_liabilities, float|int|null $shareholders_equity)  // Calculate the debt to equity ratio based on total liabilities and shareholders' equity.
float|int dividend_payout_ratio(float|int|null $total_dividends, float|int|null $net_income, int|null $decimals = null) // Calculate the dividend payout ratio based on total dividends and net income.
float|int dividend_yield(float|int|null $dividends_per_share, float|int|null $share_price, int|null $decimals = null) // Calculate the dividend yield based on dividends per share and share price.
float|int earnings_per_share(float|int|null $net_income, float|int|null $number_of_shares, int|null $decimals = null) // Calculate the earnings per share based on net income and number of shares.
float|int economic_value_added(float|int|null $net_operating_profit_after_taxes, float|int|null $capital, float|int|null $wacc) // Calculate the economic value added based on net operating profit after taxes, capital, and weighted average cost of capital (WACC).
float|int equity_ratio(float|int|null $total_equity, float|int|null $total_assets) // Calculate the equity ratio based on total equity and total assets.
float|int free_cash_flow(float|int|null $operating_cash_flow, float|int|null $capital_expenditure) // Calculate the free cash flow based on operating cash flow and capital expenditure.
float|int gdp_growth_rate(float|int|null $current_gdp, float|int|null $previous_gdp, int|null $decimals = null) // Calculate the GDP growth rate based on current GDP and previous GDP.
float|int gross_margin(float|int|null $gross_profit, float|int|null $net_sales, int|null $decimals = null)  // Calculate the gross margin based on gross profit and net sales.
float|int interest_coverage_ratio(float|int|null $ebit, float|int|null $interest_expense, int|null $decimals = null) // Calculate the interest coverage ratio based on earnings before interest and taxes (EBIT) and interest expense.
float|int internal_rate_of_return(array $cash_flows) // Calculate the internal rate of return (IRR) based on an array of cash flows.
float|int inventory_turnover_ratio(float|int|null $cost_of_goods_sold, float|int|null $average_inventory, int|null $decimals = null) // Calculate the inventory turnover ratio based on cost of goods sold and average inventory.
float|int net_margin(float|int|null $net_income, float|int|null $net_sales, int|null $decimals = null)  // Calculate the net margin based on net income and net sales.
float|int net_present_value(float|int|null $cash_flow, float|int|null $discount_rate, int $period, int|null $decimals = null) // Calculate the net present value based on cash flow, discount rate, and period.
float|int net_working_capital(float|int|null $current_assets, float|int|null $current_liabilities) // Calculate the net working capital based on current assets and current liabilities.
float|int operating_cash_flow(float|int|null $net_income, float|int|null $depreciation, float|int|null $change_in_working_capital) // Calculate the operating cash flow based on net income, depreciation, and changes in working capital.
float|int operating_cost(float|int|null $administrative_expenses, float|int|null $operational_expenses, float|int|null $sales_expenses, float|int|null $depreciation_expenses) // Calculate the operating cost based on administrative, operational, sales, and depreciation expenses.
float|int operating_income(float|int|null $net_income, float|int|null $operating_expenses, float|int|null $depreciation, float|int|null $randd_expenses) // Calculate the operating income based on net income, operating expenses, depreciation, and research and development expenses.
float|int operating_margin(float|int|null $operating_profit, float|int|null $net_sales, int|null $decimals = null) // Calculate the operating margin based on operating profit and net sales.
float|int payback_period(float|int|null $initial_investment, float|int|null $annual_cash_flows, int|null $decimals = null) // Calculate the payback period based on initial investment and annual cash flows.
float|int price_to_book_ratio(float|int|null $share_price, float|int|null $book_value_per_share) // Calculate the price to book ratio based on share price and book value per share.
float|int price_to_earnings_ratio(float|int|null $share_price, float|int|null $earnings_per_share)  // Calculate the price to earnings ratio based on share price and earnings per share.
float|int profitability_index(float|int|null $present_value_of_cash_flows, float|int|null $initial_investment, int|null $decimals = null) // Calculate the profitability index based on the present value of cash flows and initial investment.
float|int profit_margin(float|int|null $net_income, float|int|null $total_revenue, int|null $decimals = null)  // Calculate the profit margin based on net income and total revenue.
float|int quick_ratio(float|int|null $current_assets, float|int|null $inventories, float|int|null $current_liabilities) // Calculate the quick ratio based on current assets, inventories, and current liabilities.
float|int return_on_assets(float|int|null $net_income, float|int|null $total_assets, int|null $decimals = null) // Calculate the return on assets based on net income and total assets.
float|int return_on_capital_employed(float|int|null $ebit, float|int|null $capital_employed, int|null $decimals = null) // Calculate the return on capital employed based on earnings before interest and taxes (EBIT) and capital employed.
float|int return_on_equity(float|int|null $net_income, float|int|null $shareholders_equity, int|null $decimals = null) // Calculate the return on equity based on net income and shareholders' equity.
float|int return_on_investment(float|int|null $net_profit, float|int|null $investment_cost, int|null $decimals = null) // Calculate the return on investment based on net profit and investment cost.
float|int times_interest_earned(float|int|null $ebit, float|int|null $interest_expense, int|null $decimals = null) // Calculate the times interest earned based on earnings before interest and taxes (EBIT) and interest expense.
float|int working_capital(float|int|null $current_assets, float|int|null $current_liabilities)  // Calculate the working capital based on current assets and current liabilities.

*

INHERITANCES

Parents of class TEconomicsHandler

  • `TArrayHandler Methods`
    - extends `TObject`
    // [ PROPERTIES ]
    array $array  //  Array to store data.
    
    

// [ METHODS ] array chunk(int $length, bool $preserve_keys = false) // Splits the internal array into chunks. void cleanEmptyElements() // Cleans the array by removing empty elements. void cleanHTMLTags() // Cleans the array by removing HTML tags from elements. void cleanInvalidDataTypes(string $type) // Cleans the array by removing elements of invalid data types. void cleanSpecialCharacters(string $pattern = '/[^A-Za-z0-9]/') // Cleans the array by removing special characters from elements. void cleanValidURLs() // Validates and cleans the array for valid URLs. void cleanWhitespace() // Cleans the array by trimming whitespace from elements. array combine(array $keys) // Combines two arrays into an associative array. array diff(array $array) // Returns the difference between two arrays. bool empty(?array $array=null) // Checks if an array is empty. array filter(callable $callback) // Filters the array based on a callback function. bool find(mixed $element) // Finds an element in the array. array flatten(?array $array=null) // Flatten function for multidimensional arrays. array flip() // Flips the array keys and values. void fromBSON(string $filePath) // Converts binary-like format to array. void fromCSV(string $filePath) // Converts CSV format to array. void fromINI(string $filePath) // Converts INI file to array. void fromJSON(string $json) // Converts JSON string to array. void fromObject(object $object) // Converts an object to array. void fromPHPArrayFile(string $filePath) // Reads a PHP file that returns an array and assigns it to the internal array. void fromPHPVariablesFile(string $filePath) // Reads a PHP file that defines variables and assigns them to the internal array. void fromPlainText(string $filePath) // Converts plain text format to array. void fromRSS(string $rss) // Converts RSS feed format to array. void fromTOML(string $filePath) // Converts TOML format to array. void fromXML(string $xml) // Converts XML string to array. void fromYAML(string $filePath) // Converts YAML format to array. array intersect(array $array) // Returns the intersection of two arrays. array keys() // Returns the keys of the array. array map(callable $callback) // Applies a callback function to each element in the array. void merge(array ...$arrays) // Merges the internal array with one or more arrays. void merge_recursive(array ...$arrays) // Recursively merges the internal array with one or more arrays. mixed reduce(callable $callback, mixed $initial) // Reduces the array to a single value using a callback function. void replace(array ...$replacements) // Replaces the internal array with one or more arrays. void replace_recursive(array ...$replacements) // Recursively replaces the internal array with one or more arrays. void reverse() // Reverses the array. array slice(int $offset, ?int $length = null, bool $preserve_keys = false) // Returns a slice of the array. void sortAsc() // Sorts the array in ascending order. void sortDesc() // Sorts the array in descending order. void toBSON(string $filePath) // Converts array to a binary-like format and saves to file. void toCSV(string $filePath) // Converts array to CSV format and saves to file. void toINI(string $filePath) // Converts array to INI format and saves to file. string toJSON() // Converts array to JSON string. object toObject() // Converts array to an object. void toPHPArrayFile(string $filePath) // Creates a PHP file that returns the array. void toPHPVariablesFile(string $filePath) // Creates a PHP file that defines variables for the array elements. void toPlainText(string $filePath) // Converts array to plain text format and saves to file. string toRSS() // Converts array to RSS feed format. void toTOML(string $filePath) // Converts array to TOML format and saves to file. string toXML() // Converts array to XML string. void toYAML(string $filePath) // Converts array to YAML format and saves to file. array unique() // Removes duplicate values from the array. bool validateDataType(string $type) // Validates the array for specific data types. bool validateNotEmpty() // Validates the array for empty elements. bool validatePattern(string $pattern) // Validates the array for elements matching a specific pattern. bool validateRange(float $min, float $max) // Validates the array for elements within a specific range. bool validateUnique() // Validates the array for unique elements. array values() // Returns the values of the array. bool walkRecursive(callable $callback) // Applies a callback function to each element in the array recursively.


*

- `TObject Methods`

// [ PROPERTIES ]

array $properties // Array to store properties.

// [ METHODS ]

string __toString() // Returns a string containing the name of this class. bool Free(object $object) // Frees the memory of the Object or its clone. bool FreeProperties(object $object) // Delete and Frees up memory for all class properties. array getChildren(object|string|null $object_or_class = null) // Return the child classes of the given class or object bool getClassDeprecated() // Returns true if class is deprecated, otherwise false. int getClassVersion() // We get the version of the class. mixed getDeepProperty(array $keys, ?array $array = null) // Gets a property at any depth within the properties array. array getDescendantsTree(object|string|null $object_or_class = null) // Return a tree array of all descendants of the given class or object array|false getParents(object|string|null $object_or_class = null, bool $autoload = true) // Return the parent classes of the given class or object array getProperties() // Returns the table of class properties. mixed getProperty(string $property) // Returns the content of the requested property. ?array getPublicProperties() // Returns an array of the public properties of the class. int|false getVersion(string $property) // Get the version as an integer. string|false getVersionStr(string $property) // Get the version as a formatted string. bool isExecutable(int $currentVersion, int $currentPHPVersion) // Checks whether the current version of the class is executable according to the minimum and maximum versions you specify. void setDeepProperty(array $keys, mixed $value, ?array &$array = null) // Sets a property at any depth within the properties array. void setProjectVersion(int|string $version = -1) // Sets the project version. bool setProperties(array $properties, string|int|null $property_key = null) // Recursively sets properties of the class, merging sub-arrays without overwriting other data. bool setProperty(string|int $property, mixed $value, string|int|null $property_key = null) // Set a single property of the class.