This repository has been archived by the owner on Oct 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
256 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
;https://EditorConfig.org | ||
;https://github.com/editorconfig/editorconfig/wiki | ||
|
||
root = true | ||
|
||
[*.{yml,yaml,neon,xml,md,json}] | ||
charset = utf-8 | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# https://madewithlove.be/gitattributes/ | ||
|
||
/.editorconfig export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.idea export-ignore | ||
/build.xml export-ignore | ||
/docs export-ignore | ||
/phive.xml export-ignore | ||
/phpunit.xml export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/tests export-ignore | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
composer.phar | ||
/.idea/ | ||
!/.idea/dictionaries/jawira.xml | ||
/composer.phar | ||
/vendor/ | ||
|
||
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control | ||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file | ||
# composer.lock | ||
/composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Changelog | ||
========= | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
<!-- | ||
### Added | ||
### Changed | ||
### Deprecated | ||
### Removed | ||
### Fixed | ||
### Security | ||
--> | ||
|
||
Unreleased | ||
---------- | ||
|
||
### Added | ||
|
||
- Set and get php's options | ||
|
||
|
||
|
||
<!--- | ||
Guiding Principles | ||
Changelogs are for humans, not machines. | ||
There should be an entry for every single version. | ||
The same types of changes should be grouped. | ||
Versions and sections should be linkable. | ||
The latest version comes first. | ||
The release date of each versions is displayed. | ||
Mention whether you follow Semantic Versioning. | ||
Types of changes | ||
### Added for new features. | ||
### Changed for changes in existing functionality. | ||
### Deprecated for soon-to-be removed features. | ||
### Removed for now removed features. | ||
### Fixed for any bug fixes. | ||
### Security in case of vulnerabilities. | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
MIT License | ||
=========== | ||
|
||
Copyright (c) 2019 Jawira Portugal | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,47 @@ | ||
# php-ini-settings | ||
Manage your php settings | ||
@todo Project name | ||
================== | ||
|
||
<!-- | ||
BADGES: | ||
https://github.com/php-pds/badges | ||
https://poser.pugx.org/ | ||
https://php-eye.com/about#badges | ||
https://phppackages.org/p/jawira/case-converter | ||
--> | ||
|
||
Usage | ||
----- | ||
|
||
Set values: | ||
|
||
```php | ||
$ini = new Settings(); | ||
$oldValue = $ini->set('option-name','value'); | ||
``` | ||
|
||
Get values: | ||
|
||
```php | ||
$ini = new Settings(); | ||
$oldValue = $ini->get('option-name'); | ||
``` | ||
|
||
How to install | ||
-------------- | ||
|
||
@todo | ||
|
||
Requirements | ||
------------ | ||
|
||
@todo | ||
|
||
Contributing | ||
------------ | ||
|
||
To contribute to this project please read [CONTRIBUTING.md](./CONTRIBUTING.md) | ||
|
||
License | ||
------- | ||
|
||
This library is licensed under the [MIT license](LICENSE.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
|
||
<project name="PHP ini settings" description="Manage php settings" default="diagnostics"> | ||
|
||
<defaultexcludes default="true"/><!--Initializing default excludes--> | ||
<defaultexcludes add="**/.idea"/> | ||
<defaultexcludes add="**/.idea/**"/> | ||
|
||
<property name="phing.http.proxy" value="${env.http_proxy}"/> | ||
|
||
<target name="diagnostics"> | ||
<diagnostics/> | ||
</target> | ||
|
||
<target name="git:tags" description="List all git tags"> | ||
<!--https://stackoverflow.com/a/34239190/4345061--> | ||
<exec executable="git" passthru="true"> | ||
<arg value="log"/> | ||
<arg line="--graph --all --decorate --oneline --simplify-by-decoration"/> | ||
</exec> | ||
</target> | ||
|
||
<target name="changelog:links" description="Update links in composer.json"> | ||
<composer command="require"> | ||
<arg value="symplify/changelog-linker"/> | ||
</composer> | ||
<exec executable="vendor/bin/changelog-linker"> | ||
<arg value="link"/> | ||
</exec> | ||
<composer command="remove"> | ||
<arg value="symplify/changelog-linker"/> | ||
</composer> | ||
</target> | ||
|
||
<target name="php:version" description="Get current PHP version"> | ||
<exec executable="${php.interpreter}" passthru="true" checkreturn="true"> | ||
<arg value="--version"/> | ||
</exec> | ||
</target> | ||
|
||
<target name="php:lint" description="Check PHP syntax"> | ||
<property name="phplint.dir" value="src" description="Based on pds/skeleton dirs"/> | ||
<phplint haltonfailure="true"> | ||
<fileset dir="${phplint.dir}"> | ||
<include name="**/*.php"/> | ||
</fileset> | ||
</phplint> | ||
</target> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "jawira/php-ini-settings", | ||
"description": "Manage your PHP settings", | ||
"type": "library", | ||
"require": { | ||
"php": ">=7.1", | ||
"jawira/skeleton": "^1.9" | ||
}, | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Jawira Portugal", | ||
"email": "dev@tugal.be" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"Jawira\\PhpIniSettings\\": "src/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phive xmlns="https://phar.io/phive"> | ||
<configuration> | ||
<targetDirectory>bin</targetDirectory> | ||
</configuration> | ||
<phar name="phpunit" version="^7.4.4" installed="7.5.8" location="./bin/phpunit" copy="false"/> | ||
<phar name="phpstan" version="^0.10.5" installed="0.11.5" location="./bin/phpstan" copy="false"/> | ||
<phar name="phing" version="^3.0.0-alpha2" installed="3.0.0-alpha2" location="./bin/phing" copy="false"/> | ||
<phar name="behat/behat" version="^3.3.0" installed="3.3.0" location="./bin/behat" copy="false"/> | ||
<phar name="phpbench" version="^0.16.9" installed="0.16.9" location="./bin/phpbench" copy="false"/> | ||
</phive> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Jawira\PhpIniSettings; | ||
|
||
/** | ||
* Class Settings | ||
* | ||
* This is a wrapper Class to manage `ini` related functions: | ||
* | ||
* - ini_alter | ||
* - ini_get_all | ||
* - ini_get | ||
* - ini_restore | ||
* - ini_set | ||
* - php_ini_loaded_file | ||
* - php_ini_scanned_files | ||
* | ||
* @package Jawira\PhpIniSettings | ||
* @author Jawira Portugal <dev@tugal.be> | ||
*/ | ||
class Settings | ||
{ | ||
/** | ||
* Sets the value of a configuration option | ||
* | ||
* Returns the old value on success and null on failure | ||
* | ||
* @see https://www.php.net/manual/en/function.ini-set.php | ||
* | ||
* @param string $varName | ||
* @param string $newValue | ||
* | ||
* @return null|string | ||
*/ | ||
public function set(string $varName, string $newValue): ?string | ||
{ | ||
$oldValue = ini_set($varName, $newValue); | ||
|
||
return (false === $oldValue) ? $oldValue : null; | ||
} | ||
|
||
/** | ||
* Gets the value of a configuration option | ||
* | ||
* @param string $varName | ||
* | ||
* @return null|string | ||
*/ | ||
public function get(string $varName): ?string | ||
{ | ||
$value = ini_get($varName); | ||
|
||
return (false === $value) ? $value : null; | ||
} | ||
} |