Skip to content

Conversation

@atymic
Copy link

@atymic atymic commented Jul 19, 2021

No description provided.

@atymic atymic mentioned this pull request Jul 19, 2021
@codecov
Copy link

codecov bot commented Jul 20, 2021

Codecov Report

Merging #8 (e861cb3) into main (1837911) will decrease coverage by 3.13%.
The diff coverage is 81.81%.

❗ Current head e861cb3 differs from pull request most recent head e57514f. Consider uploading reports for the commit e57514f to get more accurate results
Impacted file tree graph

@@             Coverage Diff              @@
##               main       #8      +/-   ##
============================================
- Coverage     97.95%   94.82%   -3.14%     
- Complexity       18       22       +4     
============================================
  Files             1        1              
  Lines            49       58       +9     
============================================
+ Hits             48       55       +7     
- Misses            1        3       +2     
Impacted Files Coverage Δ
src/SmsLength.php 94.82% <81.81%> (-3.14%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1837911...e57514f. Read the comment docs.

@chrisminett
Copy link
Member

@atymic Thanks for updating!

I'm not sure if getPadding() is needed, as the aim of this package is to report the length. If the content means that it has to be padded into another message part, then perhaps it would be best to report that as the size. For instance, it would seem odd to report a size of 160, but taking 2 parts. It may make more sense to report a size of 161.

$this->padding could be changed to a regular variable in inspect() and included in the final value for $this->size.

@atymic
Copy link
Author

atymic commented Jan 31, 2022

@chrisminett totally forgot about this. Will fix today :)

@atymic
Copy link
Author

atymic commented Jan 31, 2022

@chrisminett ready for review now :)

Copy link
Member

@chrisminett chrisminett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating @atymic ! Not sure if I've spotted a potential issue. See comments on lines.

// Any character outside the 7-bit alphabet switches the entire encoding to UCS-2
$this->encoding = '7-bit';
$this->size = 0;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to commit a change here.

$this->messageCount = 1;
if ($this->size > $singleSize) {
$this->messageCount = (int)ceil($this->size / $concatSize);
$this->messageCount = (int) ceil($this->size / $concatSize);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to commit a change here.

$this->size++;
} elseif (in_array($char, self::GSM0338_EXTENDED, true)) {
// In cases where a double counted char straddles two messages, add padding to push it to the next part
if (($this->size + 2) % self::MAXIMUM_CHARACTERS_7BIT_CONCATENATED === 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't verified this, but I'm concerned that if the extended character is encountered at pos 153 (so also using 154) in a message whose total length that is shorter than 160, this will be adding unnecessary size.

E.g. number of characters is 159, one extended char at pos 153 with size counted as 3, pushes total size to 161 where actually it would be 160 and fit in a single message.

There should be a test for this.

if (in_array($char, self::GSM0338_BASIC, true)) {
$this->size++;
} elseif (in_array($char, self::GSM0338_EXTENDED, true)) {
// In cases where a double counted char straddles two messages, add padding to push it to the next part
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it may be clearer to say why we need to count as 3; something like:

In cases where an extended char would straddle two messages, a padding control character is added first,
so the extended character is pushed entirely to the next part".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Miscalculates number of messages when extended character is split between messages

2 participants