Comments (4)
@TomasHalasz Thank you for reporting as soon as I get Windows and XAMPP, so I'll try and fix it immediately.
Please wait until the end of this weekend.
from cnb-api.
I have the same error. And I found reason. It depends on OS type. In Linux/OSX is everything OK, but on Windows with XAMPP I got error. So in cnb-api/Cnb.php at line 33 is CSV file exploded to array by PHP_EOL:
public function getEntity(): ExchangeRate
{
$lines = explode(PHP_EOL, $this->content);
and there it is, because PHP_EOL gives (for me) wrong string in Windows OS.
I found on internet function for detecting used EOL, made some changes and solution is here:
$eol = $this->detectEol($this->content);
$lines = explode($eol, $this->content);
and function detectEol() is here:
/**Detects the end-of-line character of a string.
@param string $str The string to check.
@return string The detected EOL, or default one.
*/
private static function detectEOL($str) {
static $eols = array(
'EOL_ACORN' => "\n\r", // 0x0A - 0x0D - acorn BBC
'EOL_WINDOWS' => "\r\n", // 0x0D - 0x0A - Windows, DOS OS/2
'EOL_UNIX' => "\n", // 0x0A - - Unix, OSX
'EOL_TRS80' => "\r", // 0x0D - - Apple ][, TRS80
);
$curCount = 0;
$curEol = '';
foreach($eols as $eol) {
if( ($count = substr_count($str, $eol)) > $curCount) {
$curCount = $count;
$curEol = $eol;
}
}
return $curEol;
} // detectEOL
from cnb-api.
When I tried to reproduce the code, everything worked.
When you run this code, does it work?
$code = 'EUR';
$cnb = new \CnbApi\CnbApi();
$a = $cnb->findRateByCode($code);
print_r($a);
from cnb-api.
The same problem. Don't affect the result.
from cnb-api.
Related Issues (2)
- Upgrade of cnb-api HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cnb-api.