Skip to content

Commit

Permalink
Namespace change
Browse files Browse the repository at this point in the history
  • Loading branch information
Simbiat committed Mar 14, 2021
1 parent daae1ab commit 49a5f2f
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 88 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"autoload": {
"psr-4": {
"http20\\": "src/"
"Simbiat\\http20\\": "src/"
}
},
"support": {
Expand Down
2 changes: 1 addition & 1 deletion doc/Atom.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Atom
```php
(new \http20\Atom)->Atom(string $title, array $entries, string $id = '', string $texttype = 'text', array $feed_settings = []);
(new \Simbiat\http20\Atom)->Atom(string $title, array $entries, string $id = '', string $texttype = 'text', array $feed_settings = []);
```
Function to generate Atom feed as per https://validator.w3.org/feed/docs/atom.html specification.

Expand Down
2 changes: 1 addition & 1 deletion doc/Common.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# Common
Assortment of functions, that are used by classes inside the library, but can also be used directly. They are all called as
```php
(new \http20\Common)->nameOfFunction();
(new \Simbiat\http20\Common)->nameOfFunction();
```

## valueToTime
Expand Down
2 changes: 1 addition & 1 deletion doc/Headers.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Functions that send/handle different HTTP headers.
I hope that at some point this will become popular. While some frameworks do seem to implement some similar functionality it seems to be generally ignored, while HTTP headers can make user experience better and more secure. If you start using `Headers` (especially `security`) it will (by default) force you into following best practices when designing your website. And if you need to loosen up your security for some reason, it is possible in a relatively convinient way. And if you find that it isn't (like you need to use `unsafe` directives, for example), most likely you are trying to save a security hole, that you should not be saving.

```php
(new \http20\Headers)->nameOfFunction();
(new \Simbiat\http20\Headers)->nameOfFunction();
```

## cacheControl
Expand Down
2 changes: 1 addition & 1 deletion doc/PrettyURL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## PrettyURL
```php
(new \http20\PrettyURL)->pretty(string $string, string $whitespace = '-', bool $urlsafe = true);
(new \Simbiat\http20\PrettyURL)->pretty(string $string, string $whitespace = '-', bool $urlsafe = true);
```
Function transliterates lots of characters and makes a safe and pretty URL. This is intended more as a SEO thing, rather than sanitization.

Expand Down
2 changes: 1 addition & 1 deletion doc/RSS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## RSS
```php
(new \http20\RSS)->RSS(string $title, array $entries, string $feedlink = '', array $feed_settings = []);
(new \Simbiat\http20\RSS)->RSS(string $title, array $entries, string $feedlink = '', array $feed_settings = []);
```
Function to generate RSS feed as per https://www.rssboard.org/rss-specification specification. Function is designed similarly to Atom described above, with minor changes listed below. Otherwise - refer to feed specifications.

Expand Down
2 changes: 1 addition & 1 deletion doc/Sharing.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Sharing
Function that can be used in processes related to file sharing.
```php
(new \http20\Sharing)->nameOfFunction();
(new \Simbiat\http20\Sharing)->nameOfFunction();
```

## download
Expand Down
8 changes: 4 additions & 4 deletions src/Atom.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php
declare(strict_types=1);
namespace http20;
namespace Simbiat\http20;

class Atom
{
#Object to cache some common functions
private \HTTP20\Common $http20;
private \Simbiat\http20\Common $http20;

public function __construct()
{
#Caching common functions
$this->http20 = (new \http20\Common);
$this->http20 = (new \Simbiat\http20\Common);
}

#Function generates Atom feed (based on https://validator.w3.org/feed/docs/atom.html)
Expand Down Expand Up @@ -52,7 +52,7 @@ public function Atom(string $title, array $entries, string $id = '', string $tex
$feed_settings['updated'] = $this->http20->valueToTime($feed_settings['updated'], \DATE_ATOM);
}
#Send Last-Modified header right now, but do not exit if 304 is sent, so that proper set of Cache-Control headers is sent as well
(new \http20\Headers)->lastModified(strtotime($feed_settings['updated']), false);
(new \Simbiat\http20\Headers)->lastModified(strtotime($feed_settings['updated']), false);
#Validate authors
if (!empty($feed_settings['authors'])) {
$this->atomElementValidator($feed_settings['authors']);
Expand Down
4 changes: 2 additions & 2 deletions src/Common.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
namespace http20;
namespace Simbiat\http20;

class Common
{
Expand Down Expand Up @@ -755,7 +755,7 @@ public function atomIDGen(string $link, string|int|float|null $date = NULL): str
#Function utilizes ob functions to attempt compresing output sent to browser and also provide browser with length of the output and some caching-related headers
public function zEcho(string $string, string $cacheStrat = ''): void
{
(new \http20\Headers)->cacheControl($string, $cacheStrat, true);
(new \Simbiat\http20\Headers)->cacheControl($string, $cacheStrat, true);
#Check that zlib is loaded and client supports GZip. We are ignoring Deflate because of known inconsistences with how it is handled by browsers depending on whether it is wrapped in Zlib or not.
if (extension_loaded('zlib') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false) {
#It is recommended to use ob_gzhandler or zlib.output_compression, but I am getting inconsistent results with headers when using them, thus this "direct" approach.
Expand Down
6 changes: 3 additions & 3 deletions src/HTML.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
namespace http20;
namespace Simbiat\http20;

class HTML
{
Expand Down Expand Up @@ -68,7 +68,7 @@ public function breadcrumbs(array $items, string $delimiter = '>', bool $links =
#Send headers, if this was requested
if ($headers) {
#Create object, since we will need it twice
$headersObj = (new \http20\Headers);
$headersObj = (new \Simbiat\http20\Headers);
#Send headers
$headersObj->links($linksArr, 'header');
#Replace array of links with prepared strings for future use, if requried
Expand Down Expand Up @@ -242,7 +242,7 @@ public function pagination(int $current, int $total, int $maxNumerics = 5, array
#Send headers, if this was requested
if ($headers) {
#Create object, since we will need it twice
$headersObj = (new \http20\Headers);
$headersObj = (new \Simbiat\http20\Headers);
#Send headers
$headersObj->links($linksArr, 'header');
#Replace array of links with prepared strings for future use, if requried
Expand Down
12 changes: 6 additions & 6 deletions src/Headers.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
namespace http20;
namespace Simbiat\http20;

class Headers
{
Expand Down Expand Up @@ -206,7 +206,7 @@ public function security(string $strat = 'strict', array $allowOrigins = [], arr
break;
case 'plugin-types':
#Validate the value we have
if (preg_match('/^(('.(new \http20\Common)::mimeRegex.') ?){1,}$/i', $value) === 1) {
if (preg_match('/^(('.(new \Simbiat\http20\Common)::mimeRegex.') ?){1,}$/i', $value) === 1) {
$defaultDirectives['plugin-types'] = $value;
} else {
#Ignore the value entirely
Expand Down Expand Up @@ -364,7 +364,7 @@ public function secFetch(array $site = [], array $mode = [], array $user = [], a
}
}
#Cache mimeRegex
$mimeRegex = (new \http20\Common)::mimeRegex;
$mimeRegex = (new \Simbiat\http20\Common)::mimeRegex;
#Check if we have already sent our own content-type header
foreach (headers_list() as $header) {
if (preg_match('/^Content-type:/', $header) === 1) {
Expand Down Expand Up @@ -561,7 +561,7 @@ public function clientReturn(string $code = '500', bool $exit = true): bool
#Send response header
@header($_SERVER['SERVER_PROTOCOL'].' '.$response);
if ($exit) {
(new \http20\Common)->forceClose();
(new \Simbiat\http20\Common)->forceClose();
} else {
return $positive;
}
Expand All @@ -580,8 +580,8 @@ public function links(array $links = [], string $type = 'header', bool $strictRe
} else {
$savedata = false;
}
#Cache (new \http20\Common)
$common = (new \http20\Common);
#Cache (new \Simbiat\http20\Common)
$common = (new \Simbiat\http20\Common);
#Cache langTagRegex
$langTagRegex = $common::langTagRegex;
#Cache langEncRegex
Expand Down
4 changes: 2 additions & 2 deletions src/Meta.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
namespace http20;
namespace Simbiat\http20;

class Meta
{
Expand Down Expand Up @@ -333,7 +333,7 @@ public function msTile(array $general, array $tasks = [], array $notifications =
#Output directly to client if parameter is true
if ($prettyDirect) {
header('Content-Type: text/xml; charset=utf-8');
(new \http20\Common)->zEcho($output);
(new \Simbiat\http20\Common)->zEcho($output);
}
} else {
$output = '';
Expand Down
2 changes: 1 addition & 1 deletion src/PrettyURL.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
declare(strict_types=1);
namespace http20;
namespace Simbiat\http20;

class PrettyURL
{
Expand Down
8 changes: 4 additions & 4 deletions src/RSS.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php
declare(strict_types=1);
namespace http20;
namespace Simbiat\http20;

class RSS
{
#Object to cache some common functions
private \HTTP20\Common $http20;
private \Simbiat\http20\Common $http20;

public function __construct()
{
#Caching common functions for some performance benefits
$this->http20 = (new \http20\Common);
$this->http20 = (new \Simbiat\http20\Common);
}

#Function generates RSS 2.0 feed (based on https://www.rssboard.org/rss-specification)
Expand Down Expand Up @@ -72,7 +72,7 @@ public function RSS(string $title, array $entries, string $feedlink = '', array
$feed_settings['lastBuildDate'] = $this->http20->valueToTime($feed_settings['lastBuildDate'], \DATE_RSS);
}
#Send Last-Modified header right now, but do not exit if 304 is sent, so that proper set of Cache-Control headers is sent as well
(new \http20\Headers)->lastModified(max(strtotime($feed_settings['pubDate']), strtotime($feed_settings['lastBuildDate'])), false);
(new \Simbiat\http20\Headers)->lastModified(max(strtotime($feed_settings['pubDate']), strtotime($feed_settings['lastBuildDate'])), false);
#Check cloud
if (!empty($feed_settings['cloud'])) {
if (empty($feed_settings['cloud']['domain']) || empty($feed_settings['cloud']['port']) || empty($feed_settings['cloud']['path']) || empty($feed_settings['cloud']['registerProcedure']) || empty($feed_settings['cloud']['protocol'])) {
Expand Down
Loading

0 comments on commit 49a5f2f

Please sign in to comment.