Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop laminas-text, add related source files to Lychee #2876

Merged
merged 3 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/Assets/ArrayToTextTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

namespace App\Assets;

use Laminas\Text\Table\Decorator\DecoratorInterface;
use Laminas\Text\Table\Decorator\Unicode;
use App\Contracts\Laminas\DecoratorInterface;
use App\Metadata\Laminas\Unicode;
use Safe\Exceptions\MbstringException;
use Safe\Exceptions\PcreException;
use function Safe\mb_internal_encoding;
Expand Down
93 changes: 93 additions & 0 deletions app/Contracts/Laminas/DecoratorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php

// Copyright (c) 2020 Laminas Project a Series of LF Projects, LLC.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of Laminas Foundation nor the names of its contributors may
// be used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

declare(strict_types=1);

namespace App\Contracts\Laminas;

/**
* Interface for Laminas\Text\Table decorators.
*/
interface DecoratorInterface
{
/**
* Get a single character for the top left corner.
*/
public function getTopLeft(): string;

/**
* Get a single character for the top right corner.
*/
public function getTopRight(): string;

/**
* Get a single character for the bottom left corner.
*/
public function getBottomLeft(): string;

/**
* Get a single character for the bottom right corner.
*/
public function getBottomRight(): string;

/**
* Get a single character for a vertical line.
*/
public function getVertical(): string;

/**
* Get a single character for a horizontal line.
*/
public function getHorizontal(): string;

/**
* Get a single character for a crossing line.
*/
public function getCross(): string;

/**
* Get a single character for a vertical divider right.
*/
public function getVerticalRight(): string;

/**
* Get a single character for a vertical divider left.
*/
public function getVerticalLeft(): string;

/**
* Get a single character for a horizontal divider down.
*/
public function getHorizontalDown(): string;

/**
* Get a single character for a horizontal divider up.
*/
public function getHorizontalUp(): string;
}
158 changes: 158 additions & 0 deletions app/Metadata/Laminas/Unicode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<?php

// Copyright (c) 2020 Laminas Project a Series of LF Projects, LLC.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of Laminas Foundation nor the names of its contributors may
// be used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

namespace App\Metadata\Laminas;

use App\Contracts\Laminas\DecoratorInterface as Decorator;
use App\Exceptions\Internal\LycheeLogicException;

/**
* Unicode Decorator for Laminas\Text\Table.
*/
class Unicode implements Decorator
{
/**
* {@inheritDoc}
*/
public function getTopLeft(): string
{
return $this->_uniChar(0x250C);
}

/**
* {@inheritDoc}
*/
public function getTopRight(): string
{
return $this->_uniChar(0x2510);
}

/**
* {@inheritDoc}
*/
public function getBottomLeft(): string
{
return $this->_uniChar(0x2514);
}

/**
* {@inheritDoc}
*/
public function getBottomRight(): string
{
return $this->_uniChar(0x2518);
}

/**
* {@inheritDoc}
*/
public function getVertical(): string
{
return $this->_uniChar(0x2502);
}

/**
* {@inheritDoc}
*/
public function getHorizontal(): string
{
return $this->_uniChar(0x2500);
}

/**
* {@inheritDoc}
*/
public function getCross(): string
{
return $this->_uniChar(0x253C);
}

/**
* {@inheritDoc}
*/
public function getVerticalRight(): string
{
return $this->_uniChar(0x251C);
}

/**
* {@inheritDoc}
*/
public function getVerticalLeft(): string
{
return $this->_uniChar(0x2524);
}

/**
* {@inheritDoc}
*/
public function getHorizontalDown(): string
{
return $this->_uniChar(0x252C);
}

/**
* {@inheritDoc}
*/
public function getHorizontalUp(): string
{
return $this->_uniChar(0x2534);
}

/**
* Convert am unicode character code to a character.
*
* @param int $code
*/
// @codingStandardsIgnoreStart
protected function _uniChar(int $code): string
{
// @codingStandardsIgnoreEnd
if ($code <= 0x7F) {
return \chr($code);
}
if ($code <= 0x7FF) {
return \chr(0xC0 | $code >> 6)
. \chr(0x80 | $code & 0x3F);
}
if ($code <= 0xFFFF) {
return \chr(0xE0 | $code >> 12)
. \chr(0x80 | $code >> 6 & 0x3F)
. \chr(0x80 | $code & 0x3F);
}
if ($code <= 0x10FFFF) {
return \chr(0xF0 | $code >> 18)
. \chr(0x80 | $code >> 12 & 0x3F)
. \chr(0x80 | $code >> 6 & 0x3F)
. \chr(0x80 | $code & 0x3F);
}

throw new LycheeLogicException('Code point requested outside of Unicode range');
}
}
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
codecov:
require_ci_to_pass: true
notify:
after_n_builds: 6
after_n_builds: 9
wait_for_ci: true
comment:
behavior: default
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"geocoder-php/cache-provider": "^4.3",
"geocoder-php/nominatim-provider": "^5.5",
"graham-campbell/markdown": "^15.0",
"laminas/laminas-text": "^2.9",
"laragear/webauthn": "^3.1",
"laravel/framework": "^11.0",
"laravel/socialite": "^5.11",
Expand Down
Loading
Loading